开发者

MVC - forcing building and compiling of razor view markup

I'm not looking for much, but I want to guarantee as much as possible any re-factoring of my code has no side-effects on my front-end.

It galls me to find that I have had to re-factor e.g. Action links not to use strings as parameters (something i find horrendous), to use enums or constants for the actions and controller names.

e.g. @(Url.UserLink(UserActions.xxx))

However i find it strange that I can still enter gobbledygook for the parameter (i.e. a non-existent enum item), and the project will build. Browsing the page I get a compilation time error. However in the unit test calling the controller passes.

Can anyone suggest any work-arounds, somehow us开发者_如何学Pythoning RenderView or something from the test? At least the code should not compile!?

I haven't explored the front-end testers such as watIn or Selenium, but I guess these will be coming...


Just found this little nugget. Apparently for the default behaviour it was deemed not a good idea to allow your views to be compiled when you build, here's how to override it (edit your web .csproj project file by hand):

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    ...
    <MvcBuildViews>true</MvcBuildViews>
  </PropertyGroup>

Note the "MvcBuildViews" element is the relevant one.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜