response.redirect 未重定向到完整域名
我在重定向到同一域时遇到问题。
例如,重定向发生在 ServerA.Domain.com/Folder/application.aspx 上。但是,该程序将我重定向到 ServerA/Folder/application.aspx。
该应用程序在此域上运行良好,但我被迫重新登录。
我该怎么做才能强制重定向到同一域?
我正在使用 asp.net 3.5
已添加 我的重定向如下所示:
Response.Redirect("/Folder/application.aspx?");
I'm having an issue Redirecting to the same domain.
For example, the redirection takes place on ServerA.Domain.com/Folder/application.aspx. However, the program redirects me to ServerA/Folder/application.aspx.
The application works fine on this domain, but I'm forced to relogin.
What can I do to force the redirection to the same domain??
I am using asp.net 3.5
Added
My Redirect looks as follows:
Response.Redirect("/Folder/application.aspx?");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
如果您只是将波浪号 (~) 字符和对 ResolveClientUrl 的调用添加到重定向会怎么样?
这能解决问题吗?
What if you just add the tilde (~) character and a call to ResolveClientUrl to the redirect?
Does that take care of the problem?
看起来您在子域上尝试重定向到子域上的文件夹。我相信您需要使用完全限定的 URL:
发生的情况是您的子域是主站点上的一个文件夹,您告诉您的应用程序重定向到该文件夹。它不知道您设置了默认访问该文件夹的子域。
更新:
尝试使用
HttpContext.Current.Request.Url.xxxxx
然后附加到该内容。这样您就可以获取子域路由并以您想要的格式进行重定向。It looks like your on a sub domain trying to redirect to a folder on the sub domain. I believe you need to use the fully qualified URL:
What's happening is your sub domain is a folder on the main site, which your telling your app to redirect to. It doesn't know that you have a sub domain set up which accesses that folder by default.
Update:
Try using
HttpContext.Current.Request.Url.xxxxx
and then appending to that. This way you can probably get your sub domain route and redirect in the format you want.您可以尝试使用
Server.Transfer("/Folder/application.aspx?");
You could try using
Server.Transfer("/Folder/application.aspx?");
ResolveClientUrl 返回当前 url 的相对路径;
ResolveUrl 返回绝对路径。因此,如果在另一个文件夹下的用户控件中调用 ResolveUrl,它可能会工作得更好:
ResolveClientUrl returns a relative path to the current url;
ResolveUrl returns the absolute path. So ResolveUrl may work better in case it is called within a usercontrol under another folder: