Notes from Daily Encounters with Technology RSS 2.0
 
# Tuesday, September 19, 2006

Don’t use Configuration.Save in scenarios where users might only have read and write permissions for the configuration file as UnauthorizedAccessException will be thrown if full control is not granted. More details are available in the following MSDN Forum posting.

Tuesday, September 19, 2006 11:32:34 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Development | .NET
# Sunday, September 17, 2006

ASP.NET offers several ways of mapping nice public URLs to cryptic internal URLs matching the actual implementation.

The simplest way is to match each public URL to its internal value. You can do this by either creating dummy pages which do the redirecting or by adding them to the urlMappings section of the web.config file (brought by framework 2.0). The latter solution is preferable because of simpler maintenance but both of them have the downside of being completely static (an entry is necessary for each mapped page).

A better solution is to implement an IHttpHandler or IHttpModule and do the mapping by calling HttpContext.RewritePath(). You could also change the requested page by using Server.Transfer() or maybe even Response.Redirect() but they have their disadvantages when used for URL mapping.

To avoid having to recompile your IHttpHandler implementation every time the mapping logic changes or extends you could configure it through a custom section in the web.config file. Regular expressions are a nice tool for defining such mappings as demonstrated by here (also check the comments) or implemented in dasBlog sources (check newtelligence.DasBlog.Web.Core.UrlMapperModule). You could even use UrlRewritingNet.UrlRewrite if you don’t like reinventing the wheel.

Sunday, September 17, 2006 1:33:22 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] - Trackback
Development | .NET
# Thursday, September 07, 2006

The following code returns the time when a web resource was last modified:

static DateTime GetModificationTime(string url)
{
   WebRequest request = WebRequest.Create(url);
   HttpWebResponse response = (HttpWebResponse) request.GetResponse();
   DateTime lastModified = response.LastModified;
   response.Close();
   return lastModified;
}

It’s quite a simple piece of code actually and very similar to a sample in MSDN. But maybe it will be useful to someone since a member of my developer team was convinced that there is just no way to get this information in .NET.

Thursday, September 07, 2006 11:41:34 PM (Central European Daylight Time, UTC+02:00)  #    Comments [1] - Trackback
Development | .NET
Sponsored Ads

About Me

Microsoft Certified Professional

Microsoft Certified Professional

View Damir Arh's profile on LinkedIn

Profile for ExAmigan

ExAmigan

Twitter
I finished the redesign of http://www.damirscorner.com - now it's time to write some new content. 10 days ago
Firebug is great. It helped me solve a CSS problem within minutes. http://getfirebug.com/ 10 days ago
Enjoyed watching Coraline. Would love to get my hands on a scottish terrier puppet from the movie. http://digs.by/1ZsY 10 days ago
@DanijelMalik I guess it depends on the project you are deleting. 12 days ago
How to add static pages in DasBlog http://digs.by/1UwM 13 days ago
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

All Content © 2010, Damir Arh, M. Sc. Send mail to the author(s) - Privacy Policy - Sign In
Based on DasBlog theme 'Business' created by Christoph De Baene (delarou)