【问题标题】:IIS 8 Two Applications in One Site - Response.Redirect("~/")IIS 8 一个站点中的两个应用程序 - Response.Redirect("~/")
【发布时间】:2014-02-16 11:35:24
【问题描述】:

我是 IIS 的新手,我正在尝试在一个网站中设置两个应用程序。这就是我所做的:

我在 IIS 中创建了一个网站,并向该网站添加了两个应用程序。我可以成功导航到:

http://servername/site1
http://servername/site2

我的每一个不同的应用程序都出现了,一切似乎都运行良好。问题是我的 C# 代码中的重定向实际上重定向到什么。我尝试导航到不同的页面,如下所示:

Reponse.Redirect("~/Folder/Page.aspx");

它不是在应用程序文件夹(site1/Folder/Page.aspx) 中查找,而是在网站根目录中查找文件夹:http://servername/Folder/Page.aspx 而不是'http://servername/site1/Folder/Page.aspx。如何让 '~' 指向应用程序根目录,而不是整个网站根目录?

【问题讨论】:

    标签: c# asp.net iis-8


    【解决方案1】:

    我认为这可以解决问题:Response.Redirect(HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + HttpContext.Current.Request.ApplicationPath + "/Folder/Page.aspx")

    【讨论】:

    • 看来Request.ApplicationPath 是我的问题的解决方案。感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 2021-04-05
    • 2018-05-09
    • 2010-12-29
    • 2017-12-07
    • 2020-12-20
    • 1970-01-01
    • 2021-05-13
    • 2012-02-03
    相关资源
    最近更新 更多