Reputation:
I need a way to write the extensionless urls. My server is a Shared Host with IIS6.0 version 1. Currenty I am using UrlRewriting.Net dll,which supports only on IIS7.
My original url is abc.xyz.in/Index.aspx?c=comp_Name; My virtual url is abc.xyz.in/comp_Name.aspx but i want it as abc.xyz.in/comp_Name
Is it possible via any other module or anything. Please note mine host is shared host. So I cant either configure IIS on my own or force my admin to make modifications for the same.
Upvotes: 0
Views: 1563
Reputation: 12341
If you are starting out (or if doing so is an option), the question becomes whether or not you (your host) have ASP.Net 4 on IIS (6 or 7).
Extensionless urls are part of ASP.Net 4 - which means your ASP.Net site/s (that you want to have extensionless urls working) have to be running on ASP.net 4 (not v2.x)...
Hth...
Upvotes: 0
Reputation: 17522
The problem with custom routing in IIS6 (and older versions) is that they by default doesn't invoke the ASP.Net module unless you are asking for a .aspx, .ashx, .asmx file. There are some solutions to this that use a custom error that checks what you were trying to visit and then shows the correct page but it isn't a very nice solution (but if you really want to read more about it there is a sample over at CodeProject: http://www.codeproject.com/Articles/44475/IIS-vs-ASP-NET-URL-Rewriting).
My suggestion would be to ask your webhost to add a wildcard mapping for ASP.Net so that it handles all incoming requests to your site so you can write a proper routing module, they might not have to but there is no harm in asking and it can easily be set up on a site basis. If that is out of the question then you should probably look for a new webhost that can accommodate the needs for your site instead of adapting your site to your current webhost.
Upvotes: 1
Reputation: 3534
Hi you need to write your own HttpModule. This is a good example (it is from here): Have a look on that site, it will describe all steps needed.
using System;
using System.Web;
public class DavModule : IHttpModule {
private HttpApplication context = null;
public void Dispose() {
context.BeginRequest -= new EventHandler(context_BeginRequest);
}
public void Init(HttpApplication context) {
this.context = context;
this.context.BeginRequest += new EventHandler(context_BeginRequest);
}
void context_BeginRequest(object sender, EventArgs e) {
HttpApplication app = (HttpApplication) sender;
app.Response.ContentType = "text/plain";
if (app.Request.Path.EndsWith("Help"))
app.Server.Transfer("Help.aspx");
else {
app.Response.Write("Path: " + app.Request.Path);
app.Response.End();
}
}
}
Upvotes: 0