ASP.NET MVC 2视图页面搜索 [英] ASP.NET MVC 2 view page search

查看:61
本文介绍了ASP.NET MVC 2视图页面搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当ASP.NET MVC 2找不到特定的视图页面时,它将引发如下异常,这表明视图引擎在〜/Areas/Notices/Views/文件夹下两次对视图页面进行了查找.但为什么?谢谢,这是视图引擎中的错误吗?

When ASP.NET MVC 2 couldn''t find a particular view page, it will throw an exception something as below which shows that the view engine looks up the view page twice under ~/Areas/Notices/Views/ folder. But why? Is this a bug in the view engine, thanks.

Server Error in '/ISS' Application.
--------------------------------------------------------------------------------

The partial view 'NoticeView' was not found. The following locations were searched:
~/Areas/Notices/Views/NoticesSettings/NoticeView.aspx
~/Areas/Notices/Views/NoticesSettings/NoticeView.ascx
~/Areas/Notices/Views/Shared/NoticeView.aspx
~/Areas/Notices/Views/Shared/NoticeView.ascx
~/Views/NoticesSettings/NoticeView.aspx
~/Views/NoticesSettings/NoticeView.ascx
~/Views/Shared/NoticeView.aspx
~/Views/Shared/NoticeView.ascx
~/Areas/Notices/Views/NoticesSettings/NoticeView.aspx
~/Areas/Notices/Views/NoticesSettings/NoticeView.ascx
~/Areas/Notices/Views/Shared/NoticeView.aspx
~/Areas/Notices/Views/Shared/NoticeView.ascx
~/Views/InputBuilders/NoticeView.aspx 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

推荐答案

您好,
通常,当您未设置启动动作时,就会发生此错误.要设置启动动作,请执行以下操作:
在每个应用程序中都有一个Global.asax.打开该文件,然后设置启动控制器和操作名称.

Hi there,
This error occur usually when you don''t set the start action.. To set the start action follow this:
In every application there is a Global.asax. Open that file and set the startup controller and action name.

public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );

        }


在这种情况下,我要执行"Home"控制器的"Index"操作..

一切顺利


In this scenario I want to execute "Index" action of "Home" controller..

All the best


这篇关于ASP.NET MVC 2视图页面搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆