About the author

Vijay Kodali
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2024

Web interface for the .NET compiler

Check out compilify.net . It allows you to quickly and easily execute snippets of C# code from your browser.


Categories: C#3.0 | Web Development
Posted by vijay on Thursday, July 19, 2012 4:28 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Asp.Net Security ebook

If you want to read one book about Asp.Net security, read OWASP Top 10 for .NET developer by Troy Hunt

                There’s a harsh reality web application developers need to face up to; we don’t do security very well. A report from WhiteHat Security last year reported “83% of websites have had a high, critical or urgent issue”. That is, quite simply, a staggeringly high number and it’s only once you start to delve into to depths of web security that you begin to understand just how easy it is to inadvertently produce vulnerable code.


Posted by vijay on Thursday, December 29, 2011 6:05 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Disabled button not grayed out in Firefox and Chrome

When button is disabled, it’s not-clickable in all browsers. However in Firefox and Chrome, the button looks enabled, though the user cannot click it.

Reason:

From W3Scholl, "Enabled" Property isn't standard property of XHTML 4.

Solution:

You can modify the way they look with CSS

button[disabled] { 
 color:Grey;
/* Add other  styles here for disable button */ 
} 

Posted by vijay on Thursday, August 12, 2010 9:08 PM
Permalink | Comments (3) | Post RSSRSS comment feed

Alert user before session timeout

Here is a quick & dirty trick to alert users on session timeout. This is not a perfect solution. But it will give reader an idea to work on...

Some facts before we start:

Session doesn't end

  • When the user closes his browser
  • When the user navigates away from your page
  • When user connection lost.

Session ends, when the server hasn't gotten a request from the user in a specific time (Session timeout value).

In this solution, I am using ajaxtoolkit’s modalpopupextender control to alert user about expiring session.

Each time a page is rendered back to the client, I am injecting JavaScript that will show modalpopup two minutes before session timeout. I am passing the session expiry value to the client side java script. This will execute a countdown, and at the end display the Popup.

I added modalpopupextender to the page and set its target control id to a panel. That panel contains alert message and two buttons.

clip_image002

The Page_Load code looks like this.

clip_image004

I added two java script functions, one for showing alert message and second one is for hiding that message.

Here are javascript functions

clip_image006

That’s it. Run the application and it will check 2 minutes before the timeout and provide user the option to "slide" the session. If user clicks “OK” it will refresh page, which in turn will slide the session. If user clicks “Cancel” the popup will hide.

clip_image008

 

You can improve this code on each step. Like for example, to renew session you don’t have to refresh the page. You can just call web service from client side etc.

If you have any questions, leave a comment.


Posted by Vijay on Thursday, May 20, 2010 8:51 PM
Permalink | Comments (16) | Post RSSRSS comment feed

Visual studio Development Server problem in Vista

Problem:

Internet Explorer can not display the page.

Localhost not able to establish a connection on port..

getting the above messages when trying to run my application locally. I got this problem after installing this week's updates to Vista.  It messed up VS developer server settings. 

Apparently it was due to Definition Update for Windows Defender - KB915597 (Definition 1.53.256.0)

Solution:

Go to c:\Windows\System32\drivers\etc\ and open the file named hosts with a text editor and search for the line containing "::1"  and change "::1" to ":::1" by adding an extra ":" 

It solved the problem on one of my development machine. If it didn’t work, leave a comment.

Update:

Another solution from visual web developer team.

Update:

Same problem is discussed here and here


Posted by vijay on Thursday, March 12, 2009 1:23 PM
Permalink | Comments (42) | Post RSSRSS comment feed

8th Prize Winner of Community-Credit January 2009

I have won the 8th Prize in Community-Credit January 2009 contest.It has been an great experience to be a part of the full community and do what I like to do. But to be awarded for doing what you love to do is great.

 


Categories: General | Web Development
Posted by vijay on Wednesday, February 18, 2009 7:53 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Dynamic Accordion control same ID _header error

Multiple controls with the same ID '_header' were found. FindControl requires that controls have unique IDs.

 I got this error, when I tried adding multiple accordion panes to the accordion control in code behind. The problem is with duplicate ID for the panes. Setting unique ID's to dynamic panes will fix the problem.

<cc1:accordion id="Accordion1" runat="Server" selectedindex="0" 
  headercssclass="accordionHeader" contentcssclass="accordionContent" 
  autosize="None" fadetransitions="true" transitionduration="250"
  framespersecond="40" requireopenedpane="false" suppressheaderpostbacks="true">
</cc1:accordion>

In Code behind:

for (int i = 0; i < 3; i++)
{
    AccordionPane pane1 = new AccordionPane();
    //Here i used Guid for uniqueness
    pane1.ID = "AccordionPane" + Guid.NewGuid().ToString();
    Label lbl = new Label();
    lbl.Text = "New pane";
    pane1.Controls.Add(lbl);
    Accordion1.Panes.Add(pane1);
}


Categories: AJAX | Web Development
Posted by vijay on Monday, January 12, 2009 12:39 PM
Permalink | Comments (0) | Post RSSRSS comment feed

jQuery now officially part of the .NET toolbox

Microsoft is going to make jQuery part of the official dev platform. JQuery will come with Visual Studio in the long term, and in the short term it'll ship with ASP.Net MVC. It is truly good news for ASP.Net developers

What is jQuery?

jQuery is a lightweight open source JavaScript library.

From jQuery website..

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development.

Blogs posts by Scott Guthrie and Scott Hanselman on this topic.


Posted by vijay on Tuesday, September 30, 2008 7:11 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Detecting crawlers,bots,spiders in Asp.Net

Here is a way of detecting search engine (Google, live…) crawlers,spiders etc..

[code:c#]
            System.Web.HttpBrowserCapabilities clientBrowserCaps = Request.Browser;
            if (((System.Web.Configuration.HttpCapabilitiesBase)clientBrowserCaps).Crawler)
            {
                Response.Write ( "Browser is a search engine.");
            }
            else
            {
               Response.Write ("Browser is not a search engine.");
            } 

//Here is another approach..

            if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("Googlebot"))
            {
                //log Google bot visit
            }
            else if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("msnbot"))
            {
                //log MSN bot visit
            }
            else if (Request.ServerVariables["HTTP_USER_AGENT"].Contains("Yahoo"))
            {
                //log yahoo bot visit
            }
            else
            {
                //similarly you can check for other search engines
            }

[/code]


Posted by vijay on Tuesday, July 15, 2008 11:51 AM
Permalink | Comments (0) | Post RSSRSS comment feed

Web Application Project vs Web Site Project in Visual Studio

Web Site Project is deployed with source code to the server and all compilation takes place at runtime.

Web Application Projects, the code behind classes are compiled to dll. That dll is deployed and at runtime, the compiled code in the dll and the markup is combined to create a class which is used by the server to render output.

Update:

Good post by anthony on this

post by Stephen on this topic


Posted by vijay on Sunday, July 6, 2008 9:04 AM
Permalink | Comments (0) | Post RSSRSS comment feed