我的网络应用程序上有 2 个页面。 Login.aspx 和 Main.aspx。
成功登录用户名和密码后,我从 login.aspx 重定向到 Main.aspx,如下所示,在 C# 中。 这在 visual studio 2010 中运行良好。 问题是当我部署我的网站时,值 localhost 没有意义。
我能否确定网站运行的服务器名称,或者我是否应该以某种方式将服务器重定向主页链接放在我的 web.config 文件中?
谢谢 达摩
string Redirectport = HttpContext.Current.Request.ServerVariables["SERVER_PORT"];
RedirectURL = "http://localhost:" + Redirectport + System.Web.HttpContext.Current.Response.ApplyAppPathModifier("~/Main.aspx");
最佳答案
怎么样
RedirectURL = Page.ResolveUrl("~/Main.aspx")
?
这是执行此操作的“默认”方式。
关于c# - Asp.net 从登录重定向到主页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12848152/