English 中文(简体)
Would it be worth to remove the .aspx/.ascx lookup if I don t plan to use them?
原标题:

Now that MVC 3 Preview 1 here, we can use Razor (.cshtml) view engine. If a view not found, I get this error:

The view  a  or its master was not found. The following locations were searched:
~/Views/Home/a.aspx
~/Views/Home/a.ascx
~/Views/Shared/a.aspx
~/Views/Shared/a.ascx
~/Views/Home/a.cshtml
~/Views/Shared/a.cshtml

Would it be worth to remove the .aspx/.ascx lookup, if I don t plan to use them?

最佳回答

I doubt you would gain any noticeable performance gain from that. It s merely a file check and if it s also cached by the engine there s hardly any performance improvement. I d call it micro-optimization!

I guess if you know you won t be using WebForms, you could just remove it from the list of view engines, like so:

ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());

That way it won t check for aspx/ascx files.

问题回答

The Code has been revised:

ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());




相关问题
How to update shared view adminheader.cshtml from a model

I ve added a drop down into my shared adminheader.cshtl view and it needs to be dynamically updated from data from a table. So when I use another view like routeplan.cshtml I load the view from ...

ASP.NET MVC Razor view engine

After reading Scott Guthrie s blog entry about the new Razor view engine for ASP.NET MVC and reading this question comparing the available view engines. Razor seems to address most of the problems ...

Client Id for Property (ASP.Net MVC)

I m trying to do a label for a TextBox in my View and I d like to know, how can I take a Id that will be render in client to generate scripts... for example: <label for="<%=x.Name.ClientId%>"...

Get Current Area Name in View or Controller

How do you get the current area name in the view or controller? Is there anything like ViewContext.RouteData.Values["controller"] for areas?

MVC which submit button has been pressed

I have two buttons on my MVC form: <input name="submit" type="submit" id="submit" value="Save" /> <input name="process" type="submit" id="process" value="Process" /> From my Controller ...

热门标签