且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何重定向URL ASP.NET MVC

更新时间:2022-10-18 19:19:50

这里似乎有多个问题:



1。 ASP.NET MVC使用路由将URL定向到Controller并运行特定操作。它不是为直接导航到View而设计的。您需要验证路由是否已正确设置,并且无法以此方式导航。允许它也存在安全风险。



2.应调整GoDaddy重定向以进入特定路线;默认情况下或特殊情况如果有保证。



3.然后出现太多重定向问题。有很多问题可能导致这种情况,我只能给你经常看到的问题:



- HTTP& HTTPS。该网站可能没有SSL,只支持HTTP,并且有一个升级标头冲突。



- 会话。在Session_Start上检测浏览器,并重定向到移动页面。如果设备被锁定且不接受cookie,Session_Start将触发每个请求并重定向您。





我会采取关注物品1& 2首先。当你到达#3时,我会使用浏览器检查器来观察网络活动,以查看你从哪里循环到


on godaddy in dns management ,in forwarding domain section i have set something like xyz/abc/form.cshtml . Now url is opening by this path but error is giving too many redirect urls or 502 bad gateway.

What I have tried:

on godaddy in dns management ,in forwarding domain section i have set something like xyz/abc/form.cshtml  . Now url is opening by this path but error is giving too many redirect urls or 502 bad gateway. 

You appear to have multiple problems here:

1. ASP.NET MVC uses routing to direct a URL to a Controller and run a specific action. It was not designed to navigate directly to a View. You will need to verify that your routes are setup properly and that you cannot navigate that way. Allowing it is also a security risk.

2. GoDaddy redirect should be adjusted to go a specific route; either the default or something special if warranted.

3. And then there is the "too many redirects" issue. There are a multitude of problems that could cause this, I can only give you frequent ones I have seen:

- HTTP & HTTPS. The site may not have an SSL and only support HTTP, and there is an upgrade header conflicting.

- Sessions. Browser detection on Session_Start, and redirect to mobile page. If the device is locked down and doesn't accept cookies, Session_Start will fire on each request and redirect you.


I would take care of items 1 & 2 first. When you get to #3 I would use the browser-inspector to watch the network activity to see where you are looping from and to