[英]IIS throwing HTTP 404 not found but resource exists. Requested URL also changing automatically.!
I'm facing a really weird scenario here with my local IIS. 我的本地IIS在这里面临着一个非常奇怪的情况。 I have hosted multiple sites in the default website in my local IIS.
我已经在本地IIS的默认网站中托管了多个网站。 One of them has the login page.
其中之一具有登录页面。 From the login page, I'm redirecting the user to another page that is located in another site (which is also hosted in the same IIS inside default website virtual directory).
从登录页面,我将用户重定向到位于另一个站点(也位于默认网站虚拟目录内的同一IIS中)的另一个页面。
Now in the submit button click event of my login page, after authenticating the user, I have written a " Response.Redirect( redirect_url ) ".
现在,在登录页面的“提交”按钮单击事件中,对用户进行身份验证之后,我编写了“ Response.Redirect( redirect_url ) ”。 the redirect_url is being formed dynamically and given as a parameter to the
Redirect method.
redirect_url是动态形成的,并作为Redirect方法的参数提供。
While debugging, the final redirect_url that is being sent as parameter to Redirect method is:
调试时,作为参数发送给Redirect方法的最终redirect_url是:
http://localhost/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
But after I try to go to the next step, I'm suddenly getting a HTTP 404 error saying that the resource doesn't exist and I have observed that Requested URL shown in the error page is different that what was dynamically sent to the
Response.Redirect(...) method.
但是,在尝试进行下一步之后,我突然收到一个HTTP 404错误,提示该资源不存在,并且我发现错误页面中显示的Requested URL与动态发送给
Response的
URL不同。
.Redirect(...)方法。
In the error page, the requested url shows the value as 在错误页面中,所请求的网址将值显示为
http://localhost/CP/web/console/localhost/CPLogin?err=5
whereas my actual requested url formed in the code is:
而我在代码中形成的
实际要求的网址是:
http://localhost/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
I'm just unable to understand why the requested url is getting changed automatically.! 我只是无法理解为什么请求的网址会自动更改。 Also, I observe that "localhost" is being appended to the requested URL again which is not what is supposed to happen.
另外,我发现“ localhost”再次被附加到请求的URL,这不是应该发生的情况。
Please visit THIS link [^] to understand this question more clearly. 请访问此链接 [^]以更清楚地了解此问题。 I have added screen shot of the error page.
我添加了错误页面的屏幕截图。
http://amoghnatu.wordpress.com/2013/09/16/question-please-help-iis-throwing-http-404-not-found-but-requested-resource-actually-exists-requested-url-also-changing-automatically/ [^] http://amoghnatu.wordpress.com/2013/09/16/question-please-help-iis-throwing-http-404-not-found-but-requested-resource-actually-exists-requested-url-also-自动更改/ [^]
Thanks a lot.! 非常感谢。!
Indeed, the problem was with the way I had hosted the sites in my application. 确实,问题出在我在应用程序中托管网站的方式。 I just removed all the sites related to my application from IIS and then hosted all of them again much more carefully.
我刚刚从IIS中删除了与我的应用程序相关的所有站点,然后再次更加仔细地托管了所有这些站点。 This resolved the "wrong redirect url" problem.
这解决了“错误的重定向URL”问题。
Also, I had some tables with missing required data because of which I was getting the error code. 另外,我有一些表缺少必需的数据,因此我收到了错误代码。
So after I got all the tables filled with the required data and also after properly hosting the application in IIS, my problem got resolved. 因此,在我将所有表都填充了所需的数据之后,并且在将应用程序正确地托管在IIS中之后,我的问题得到了解决。
In IIS, go to relevant folder, right click and "browse". 在IIS中,转到相关文件夹,右键单击并“浏览”。 Check out what is the URL.
查看什么是URL。 In most cases, this is due to the URL should have port number appended.
在大多数情况下,这是由于URL应当附加端口号。 For instance it will be something like :
例如,它将类似于:
http://localhost:<port number>/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
instead of 代替
http://localhost/CP/web/console/console.aspx?sk=3e3cc1a8-73c4-4945-b3f8-08af22ea4324.50008
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.