首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Response.Redirect()可以在Visual Studio中使用,但不能在IIS中使用

问Response.Redirect()可以在Visual Studio中使用,但不能在IIS中使用
EN

Stack Overflow用户
提问于 2017-03-23 03:03:58
回答 3查看 1.2K关注 0票数 1

我正在尝试将一个基本的web应用程序从Windows 7上的visual studio上载到Windows Server 2007上的IIS环境。

虽然从IIS启动它会显示登录页面,但尝试导航到主菜单时会返回以下错误:

代码语言:javascript
复制
Server Error in Application "PARKING/PARKING ASSIGNMENTS WEB"Internet Information Services 7.0
Error Summary
HTTP Error 404.0 - Not Found
The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Detailed Error Information
Module IIS Web Core 
Notification MapRequestHandler 
Handler StaticFile 
Error Code 0x80070002 
Requested URL http://localhost:81/Parking Assignments Web/Home 
Physical Path C:\ParkingAssignmentsWeb\Home 
Logon Method Anonymous 
Logon User Anonymous 
 Most likely causes:
•The directory or file specified does not exist on the Web server.
•The URL contains a typographical error.
•A custom filter or module, such as URLScan, restricts access to the file.
 Things you can try:
•Create the content on the Web server.
•Review the browser URL.
•Create a tracing rule to track failed requests for this HTTP status code and see which module is calling SetStatus. For more information about creating a tracing rule for failed requests, click here. 
 Links and More InformationThis error means that the file or directory does not exist on the server. Create the file or directory and try the request again. 
View more information »

这是我用来导航的代码:

代码语言:javascript
复制
Response.Redirect("Home.aspx");

为什么此导航在Visual Studio上有效,而在IIS上无效?

更新:我尝试了你们展示给我的重定向命令的变体,但它们都给出了404错误,这让我相信问题不是命令的问题,而是其他的问题。知道是什么吗?

EN

回答 3

Stack Overflow用户

发布于 2017-03-23 03:15:51

请尝试:

代码语言:javascript
复制
Response.Redirect("~/Parking Assignments Web/Home.aspx");

或

代码语言:javascript
复制
Response.Redirect("~/Parking Assignments Web/Home");
票数 0
EN

Stack Overflow用户

发布于 2017-03-23 03:20:13

它将Home.aspx视为相对路径。

像这样使用它:

代码语言:javascript
复制
Response.Redirect("/Home.aspx");
票数 0
EN

Stack Overflow用户

发布于 2017-03-23 03:21:37

当您部署到IIS时,将使用不同的web服务器。Visual studio使用具有有限选项的web服务器,并且在大多数情况下(但不是所有情况下),当应用程序部署到windows服务器上的IIS时,应用程序应该在不做任何更改的情况下运行。

要检查的事项

  • 验证工作站上的文件夹结构与部署到服务器上的文件夹结构是否相同。
  • 检查web上IIS访问的文件夹的权限假定文件与调用传输文件夹的页面位于同一目录中。添加更完整的路径(“

”)或("/ folder /home.aspx"),其中server

  • Response.Redirect("Home.aspx");是包含.aspx

的实际文件夹名

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/42960552

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档