Suppress Debug Window on application crash

by dee 15. January 2008 23:59

Set HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Auto to 0

HttpOnly Cookies

by dee 15. January 2008 02:04

HttpOnly cookies are a Microsoft extension to the cookie standard. The idea is that cookies marked as httpOnly cannot be accessed from JavaScript. This was implemented to stop cookie stealing through XSS vulnerabilities. This is unlike many people believe not a way to stop XSS vulnerabilities, but a way to stop one of the possible attacks (cookie stealing) that are possible through XSS.

ASP.NET uses that feature by default and thus there is no possibility to access to cookies which are marked as httpOnly (for example "ASP.NET_SessionId") in Internet Explorer. To turn it off add following settings to web.config file:

<system.web>
    <httpCookies httpOnlyCookies="false" />
</system.web>

How to enable IIS SMTP to relay emails from any computers

by dee 14. January 2008 13:48

If you get error like "Unable to relay ..." while sending email you should do the following: open properties of your default SMTP server, select "Access" tab, click on "Relay" button under "Relay restrictions" group, switch radio list to "All except the list below' as shown at followed screenshot.

Tags: , ,

ASP.NET

ASP.Net Events issue

by dee 7. January 2008 18:41

ASP.NET is not able to load types of custom web events if they are placed under App_Code directory. Most probably it happens because Type.GetType() method is used, which cannot load ASP.NET 2.0 App_Code types since they are available during execution time only. We should use System.Web.Compilation.BuildManager.GetType() method instead. For now the solution is only to separate needed type to another assembly and point configuration to it.

AJAX and error handling

by dee 7. January 2008 18:34

Use followed code to catch AJAX errors:

 

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function EndRequestHandler(sender, args)
{
   if (args.get_error() != undefined && args.get_error().httpStatusCode == '500')
   {
       var errorMessage = args.get_error().message;
       args.set_errorHandled(true);
       alert(errorMessage);
   }
}

Session object in Session_End event

by dee 3. January 2008 14:59

Trying to use HttpContext.Current.Session in Session_End event of Global.asax will result in NullRefenceException. Use just Session (without HttpContext.Current) object instead.

IIS and Url Rewrite module

by dee 2. January 2008 20:25

To enable IIS to work with custom .Net Url Rewrite module it's needed to do following: open "Properties" of web site -> "Home Directory" tab -> "Configuration" button. Click on "Insert" button which is located under "Wildcard application maps" label. You should point "Executable" to aspnet_isapi.dll and clear "Verify that file exists" checkbox.

Debugger.Break() and IIS issue

by dee 2. January 2008 18:01

For debugging it is very useful to use followed code in Global.asax:

void Application_Error(object sender, EventArgs e)
{
    System.Diagnostics.Debugger.Break();
}

But if you deploy it on IIS then in case of unhandled exception the followed dialog window will be shown for current logged on user:

The solution is to remove System.Diagnostics.Debugger.Break(); from code before deploying.

Powered by BlogEngine.NET 1.4.0.0
Theme by Mads Kristensen