Showing posts with label .net. Show all posts
Showing posts with label .net. Show all posts

Sunday, April 19, 2009

WordPress Mod: Authenticate via ASP.NET


I hooked up a WordPress blog to authenticate via ASP.NET. It's wicked, I tell you! After hacking through the WordPress source code, the integration was quick and easy from both the PHP and ASP.NET sides. The purpose of the integration was to deal with differences in hash algorithms, so we wouldn't have to create user accounts with completely different passwords.

We still would have to build a component on the ASP.NET side to push profile changes and new user accounts into WordPress. I'm wondering if MS SQL Server can connect to MySQL and update the data from within a trigger.

Monday, April 13, 2009

HttpResponse.Close instead of HttpResponse.End

When profiling my application, I noticed that Response.End takes more time to execute than Response.Close. I'm guessing this is because Response.End causes a ThreadAbortException and .NET's handling of the exception causes the overhead.

Monday, April 6, 2009

Manual Sliding Expiration

When using ASP.NET Forms Authentication, ASP.NET sets a timeout of 30 minutes by default for which a user is logged in. If the user does make a request within the 30 minutes, the authentication ticket is renewed for a another period. This normally happens behind the scenes and the developer is often not aware of this process, known as sliding expiration.

However, if you've got some pages on your web application that should be viewable by the user without the authentication ticket being renewed (such as a ticker to display new messages within an IFrame), you can disable slidingExpiration by making the following change in the web.config file:

<authentication mode="Forms">
<forms slidingExpiration="false"></forms>
</authentication>

You then have to programatically perform sliding expiration within your code, which can be done with the following code snippet posted at:
http://forums.asp.net/p/1083581/1607975.aspx

// Acquire Auth Ticket from the FormsIdentity object
FormsAuthenticationTicket objOrigTicket = ((FormsIdentity)Context.User.Identity).Ticket;

if (!Request.Url.AbsolutePath.ToLower().EndsWith(".ashx"))
{
// Manually slide the expiration
FormsAuthenticationTicket objNewTicket = FormsAuthentication.RenewTicketIfOld(objOrigTicket);

if (objNewTicket.Expiration > objOrigTicket.Expiration)
{
// Create the (encrypted) cookie.
HttpCookie objCookie = new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(objNewTicket));
// Add the cookie to the list for outbound response.
Response.Cookies.Add(objCookie);
// Update original
objOrigTicket = objNewTicket;
}
}

In the code snippet above, you would have to change the condition within the IF statement that checks Request.Url to exclude the pages for which you do not want slidingExpiration to occur. The example above excludes all requests to ASP.NET Generic Handlers (files ending in .ashx).

Sunday, April 5, 2009

ASP.NET MVC 1.0 Source Code

For those of you who are still in the dark, the ASP.NET MVC 1.0 source code is available for download at:
http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471

Friday, April 3, 2009

New Path For .NET 4 Certification

It's quite likely that the certification path for .NET 4 may be significantly different from the ones for .NET 2.0 and .NET 3.5. The certification path for .NET 2/3.5 requires test-takers to take a foundation exam that covers various topics.

The change would be welcomed by many professionals. After all, how many ASP.NET and Silverlight developers want to spend time learning COM interop instead of focusing on their core competencies?