加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – 在vs 2010中运行asp.net mvc 2项目时出错

发布时间:2020-12-16 07:08:03 所属栏目:asp.Net 来源:网络整理
导读:我创建了一个新的解决方案,它构建了精细的目标框架4.0但是当我运行它时,我的浏览器出现了: 无法找到该资源. 说明:HTTP 404.您要查找的资源(或其中一个依赖项)可能已被删除,名称已更改或暂时不可用.请查看以下网址,确保拼写正确. 请求的网址:/ 关于如何调
我创建了一个新的解决方案,它构建了精细的目标框架4.0但是当我运行它时,我的浏览器出现了:

无法找到该资源.
说明:HTTP 404.您要查找的资源(或其中一个依赖项)可能已被删除,名称已更改或暂时不可用.请查看以下网址,确保拼写正确.
请求的网址:/

关于如何调试这个的任何想法?

解决方法

尝试添加asp.net mvc 1.0项目模板附带的default.aspx页面.在IIS 5(XP)的计算机上运行mvc 2时出现了类似的问题,这就解决了这个问题.

Default.aspx的:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="YourNamespace.Website.Default" %>

<%-- Please do not delete this file. It is used to ensure that ASP.NET MVC is activated by IIS when a user makes a "/" request to the server. --%>

Default.aspx.cs:

using System.Web;
using System.Web.Mvc;
using System.Web.UI;

namespace YourNamespace.Website
{
    public partial class Default : Page
    {
        public void Page_Load(object sender,System.EventArgs e)
        {
            // Change the current path so that the Routing handler can correctly interpret
            // the request,then restore the original path so that the OutputCache module
            // can correctly process the response (if caching is enabled).
            string originalPath = Request.Path;
            HttpContext.Current.RewritePath(Request.ApplicationPath,false);
            IHttpHandler httpHandler = new MvcHttpHandler();
            httpHandler.ProcessRequest(HttpContext.Current);
            HttpContext.Current.RewritePath(originalPath,false);
        }
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读