I am running a small intranet site off Windows 7 and IIS and I have a page page/LoadPage.aspx
which is an ASPX container page for displaying a requested page, e.g. http://localhost/page/LoadPage.aspx?p=downloads
(which loads downloads.html
located in the root directory).
The problem is, when creating a User-Friendly URL using the URL Rewrite plugin in IIS 7, if the query tag (p
) requests a page in a particular directory (e.g. http://localhost/page/LoadPage.aspx?p=downloads/software
, which should load the page downloads/software.html
) then a 404 error will be thrown because the server thinks the user has requested a directory.
The mapping and redirecting do work for single requests like page/LoadPage.aspx?p=downloads
which successfully redirects to http://localhost/downloads.html
.
Thank you.
UPDATE: Here is the code. Could it be the problem?
Example URL: /page/LoadPage.aspx?p=downloads
(This works and redirects to downloads.html
)
Example URL: /page/LoadPage.aspx?p=downloads/software
(This doesn't work, but is meant to redirect to /downloads/software.html
)
Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
Dim p = Request.QueryString("p").ToString
Dim page = HttpUtility.UrlDecode(p)
Dim ReadHTML As New IO.StreamReader("\\PC\User\Documents\IIS Websites\Intranet\" & page & ".html")
container.InnerHtml = ReadHTML.ReadToEnd
End Sub
Best Answer
/
is a reserved character, so you will need to url encode the querystring value.Your URL should look like this:
To use the value in your .NET code, you will need to decode the value:
https://msdn.microsoft.com/en-us/library/adwtk1fy.aspx