重定向网页请求到一个默认的子文件 [英] Redirect Web Page Requests to a Default Sub Folder
问题描述
我使用UltiDev Web服务器Pro和有我所有的aspx文件都位于一个子文件的WebForms。
我希望能够为页面的所有请求默认使用此文件夹,这样他们可以只输入: HTTP://myserver/somepage.aspx
而不是
HTTP://myserver/WebForms/somepage.aspx
这可能吗?
编辑:
下面是解决方案的VB.NET版本低于包括大小写检查:
如果不HttpContext.Current.Request.Path.ToUpper.Contains(/ web表单/)然后
Context.RewritePath(/ WebForms的+ HttpContext.Current.Request.Path,假)
万一
您可以使用的Global.asax
和的Application_BeginRequest
到 RewritePath
到最终目的地,仍然有没有在的WebForm 路径的链接。
保护无效的Application_BeginRequest(对象发件人,EventArgs的发送)
{
如果(!HttpContext.Current.Request.Path.Contain(/的WebForms /))
RewritePath(/ WebForms的+ HttpContext.Current.Request.Path,FALSE);
}
I am using UltiDev Web Server Pro and have all my aspx files are located in a sub folder 'WebForms'.
I want to be able to default all requests for pages to this folder such that they can just type:
http://myserver/somepage.aspx
instead of
http://myserver/WebForms/somepage.aspx
.
Is this possible?
EDIT:
Here is the VB.NET version of the solution below including a check for case sensitivity:
If Not HttpContext.Current.Request.Path.ToUpper.Contains("/WEBFORMS/") Then
Context.RewritePath("/WebForms" + HttpContext.Current.Request.Path, False)
End If
You can use the Global.asax
and the Application_BeginRequest
to RewritePath
to the final destination and still have the link without the WebForm path.
protected void Application_BeginRequest(Object sender, EventArgs e)
{
if(!HttpContext.Current.Request.Path.Contain("/WebForms/"))
RewritePath("/WebForms" + HttpContext.Current.Request.Path, false);
}
这篇关于重定向网页请求到一个默认的子文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!