Carl
Mon Nov 07 14:39:16 CST 2005
There's a (in my opinion) smarter way to do this.
Create a IHttpModule and let it check all incoming requests.
And then do something like this in the module:
#region IHttpModule Members
public void Init(System.Web.HttpApplication application)
{
// TODO: Add UrlRewriteModule.Init implementation
application.BeginRequest +=new
EventHandler(application_BeginRequest);
}
public void Dispose()
{
// TODO: Add UrlRewriteModule.Dispose implementation
}
#endregion
private void application_BeginRequest(object sender, EventArgs e)
{
//cast the sender to an HttpApplication object
System.Web.HttpApplication Appl=(System.Web.HttpApplication)sender;
string originalPath = Appl.Request.Path.ToLower();
// Check if the originalPath ends with a slash
if(originalPath.EndsWith("/"))
{
// check if default.aspx exists
FileInfo fi = new
FileInfo(Appl.Request.PhysicalPath+"\\default.aspx");
if(fi.Exists)
{
Appl.Response.Redirect("default.aspx",true);
}
}
else
{
// Check if we have a "directory-like" url
Match m = Regex.Match(originalPath, @"([/a-zA-Z0-9-_]+)");
if(m.Success && m.Index == 0 && m.Length == originalPath.Length)
{
// Could be a directory...
FileInfo fi = new
FileInfo(Appl.Request.PhysicalPath+"\\default.aspx");
if(fi.Exists)
{
Appl.Response.Redirect(originalPath+"/default.aspx",true);
}
}
}
}
Tiziana Loporchio MCSD.NET wrote:
> After opening an Incident with Microsoft ,
> the workaround for this version of Asp.net 1.1 and IIS 6.0 is :
> - The Web site is not configured for the "application wildcard
> mapping" and we have got only one page "default.aspx" that does only
> Response.Redirect("ApplicationDirectory\SomePage.aspx")
>
> - The "ApplicationDirectory" virtual directory is your ASP.NET
> application with "application wildcard mapping"
>
> Conclusion:
>
> - Users browse
http://www.example.com/, the default.aspx executes
> and redirects to
http://www.example.com/ApplicationDirectory/SomePage.aspx
>
> - There is no problem with Session state and application state
> because the default.aspx page is only there to redirect the user. The
> application is only hosted in one unique virtual directory
> "ApplicationDirectory"
>
> I hope my issue helps someone else.
>
> Thanks to Microsoft for support
>
> Bye
>
> Tiziana
>
> "David Wang [Msft]" <someone@online.microsoft.com> ha scritto nel messaggio
> news:%23uJK5BW0FHA.2008@TK2MSFTNGP10.phx.gbl...
> > Ok, this got me to nail down some of my long outstanding blog posts - IIS6
> > request pipeline basics - and then apply it in the case of how wildcard
> > application mapping interacts with IIS6.
> >
> >
>
http://blogs.msdn.com/david.wang/archive/2005/10/15/Why_Wildcard_application_mapping_can_disable_Default_Document_resolution.aspx
> >
>
http://blogs.msdn.com/david.wang/archive/2005/10/14/HOWTO_IIS_6_Request_Processing_Basics_Part_1.aspx
> >
> > The short answer to your question is:
> > - This is not a bug in IIS6 nor ASP.Net.
> > - If you use ASP.Net ISAPI from ASP.Net 1.0 or 1.1, then disabling default
> > document is by design with no workarounds other than rewriting IIS code to
> > do DefaultDoc resolution.
> > - If you use ASP.Net ISAPI from ASP.Net 2.0, then it should just work.
> >
> > --
> > //David
> > IIS
> >
http://blogs.msdn.com/David.Wang
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
> > //
> > "Tiziana Loporchio MCSD.NET" <tloporchio@hotmail.com> wrote in message
> > news:ur4AQX8zFHA.1640@TK2MSFTNGP12.phx.gbl...
> > I use the ASP.NET ISAPI.
> > I need that all request are passed to asp.net.
> > How can I do it ?
> >
> > Thanks
> >
> >
> > "Kristofer Gafvert [MVP]" <kgafvert@NEWSilopia.com> ha scritto nel
> messaggio
> > news:xn0e8ewccepj7r300c@news.microsoft.com...
> > > What ISAPI did you set as the wildcard application mapping?
> > >
> > > If the ISAPI application you have defined as a wildcard application
> > > mapping is not designed to be this, it will probably break DefaultDoc.
> > >
> > > The only ISAPI application i am aware of that ships with IIS 6.0 and
> > > supports wildcard application mapping is URLAuth. So if your ISAPI
> > > application is something else, you may want to contact the developer.
> > >
> > >
> > > --
> > > Regards,
> > > Kristofer Gafvert (IIS MVP)
> > >
http://www.gafvert.info/iis/ - IIS Related Info
> > >
> > >
> > > Tiziana Loporchio MCSD.NET wrote:
> > >
> > > >On IIS6 I have configured a wildcard application mapping, but now when
> I
> > > >just browse to a URL or an IP without specifying a document, it does
> not
> > > >add
> > > >the "default document" anymore. Is it a bug in IIS 6.0 ?
> > > >
> > > >Does anyone know a workaround? Or does anyone have code to replace the
> > > >"default document settings" in an isapifilter? I don't have any clue
> how
> > to
> > > >do that.
> > > >
> > > >Any help would be very much appreciated
> > > >Tiziana
> >
> >
> >