Asp.net从登录重定向到主页面

use*_*082 2 c# asp.net web-config iis-7.5

我的webapp上有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");
Run Code Online (Sandbox Code Playgroud)

Ewe*_*ton 9

怎么样

RedirectURL = Page.ResolveUrl("~/Main.aspx")

这是"默认"的方式.