Tagged asp-netTim Stanley

Use HostingEnvironment.MapPath

Jun 25, 2010 EST

When running a service under IIS, the HttpContext.Current object is not available, so HttpContext.Current.Server.MapPath will fail.

fileName = HttpContext.Current.Server.MapPath(fileName);

The solution is to use Hosting.HostingEnvironment.MapPath instead.

fileName = System.Web.Hosting.HostingEnvironment.MapPath(fileName);

Custom Controls In ASP.NET

Feb 26, 2010 EST

ASP.net has that neat little feature where all the controls can start with <asp:.  It makes it easy to code.  I had numerous custom controls and I always had to register the control on each page to use it.  Scott Guthrie had a great tip on how to register the controls in the web.config file so that it doesn’t have to be done in each page.More...

Pretty URLs And IIS6

May 12, 2009 EST

IIS7 can support pages without extensions without administrator configuration settings. IIS6 can also support  URLs without extensions, but it requires an administrator setting. Here's a tip on how to configure IIS6 to support URLs without extensions.More...

Pretty Good URLs

Mar 13, 2009 EST

With a little forethought and planning, it’s possible to create URLs that can be around the web for a long time and as Tim Berners-Lee pointed out cool URIs don't change.  Choose wisely though, you may have to live with the URLs for much longer than you think, or if your not careful, you may end up with too many URLs pointing to the same content. More...

How To Restart ASP.Net Applications

Feb 23, 2009 EST

Many times, from an administration perspective, it's desirable to restart an ASP.NET web site without restarting IIS on the whole server. More...

Using Cache And Compression For Performance

Sep 24, 2008 EST

Most browsers and servers have default values that provide fairly good performance with a minimum caching of static file content.  A little bit of coaxing can result in better performance with less traffic and less bandwidth.

There are two types of caching I discuss: static content  (*.JPG, *.JPEG, *.png, *.gif, *.ico) rarely updated and semi-static content (*.js, *.css) updated very infrequently.  The decision to cache page output (*.aspx, *.html, *.htm) long term is too dependent on application functionality decisions to discuss generically. More...

ASP.Net Cached XML File Settings

Apr 15, 2008 EST

How to use ASP.Net Cache settings to automatically read and update values from an XML file when the file is updated, and how to lookup a value in the XML file.

.Net surprises me every day.  I think about how I want to do things and then I dig a little (some time a lot) into .Net components and viola, I find it provides some new interesting functionality that I didn't know about before. 

I recently wanted to implement some features for using configuration values for an ASP.NET application.  My requirements were as follows. More...