views:

37

answers:

2

Hi All,
I am trying to add page with custom extension, say .asp2 with my set of html tags. Now whenever i try to access the page on browser...it asks me "Save as". This happens because I am using an extn which the server is not able to recognise. What should I do to so that my server, IIS 5.1 recognises this extension??

Please suggest

Also please suggest on how to associate custom events on such custom page?

A: 

Using a non-standard extension, you should also be sure to set the response's Content Type to text/html, so the browser knows how to interpret the document you're sending. Something like:

public class HttpHandler1 : IHttpHandler
{
  public bool IsReusable
  {
    get { return true; }
  }

  public void ProcessRequest(HttpContext context)
  {
    context.Response.ContentType = "text/html";

    // Your code here.
  }
}
Dave Ward
Hi Dave,How do I associate this in my code...?
Justin
You should be able to add that single line into your existing HttpHandler's ProcessRequest method. If that doesn't work, update your question with some of your actual code, so that we/I can give you more specific advice.
Dave Ward
I don't think this will work on it's own. Because IIS won't be passing this unknown extension through the asp.net engine without being told to do so first. Might need a combination of this answer, and pdr's.
DaRKoN_
You're right, both steps are necessary. I think Justin has that covered though, judging from his comment on pdr's answer. If he didn't have IIS configured for that extension, it wouldn't serve the file at all (which isn't the behavior he's seeing).
Dave Ward
Hey, its working fine after we add an entry within the <httpHandlers> of web.config. Thus it will be able to associate the which handler to call.
Justin
But now I am working on how to handle events on my custom page... :)
Justin
A: 

In Internet Services Manager, right click on Default Web Site, select Properties, in Home Directory press the Configuration button. Click the Add button and fill the Executable field with the path to the aspnet_isapi.dll file and put asp2 in the Extension field.

pdr
Hey,Thanks for your quick reply. Actually I have done the same by adding separate extension for .asp2 and adding path for aspnet_isapi.dll file. But still it is not able to recognise the extension. I have also restarted the IIS server. still not working.
Justin
In that case, it will be the content type in the header, as per the other answer.
pdr