Edi Wang

.NET and Azure Developer

Razor

Fix Visual Studio 2015 Razor Editor Blow Up

Visual Studio 2015 has been RTM for one month. However, it blows up very often, such as Razor editor. When I try to open any .cshtml file, it blows up with this error, then the syntax highlight is gone. I tried to uninstall all add-on, even repair install VS2015 can't get it working. The detailed error message is: System.Reflection.TargetInvocationException: Exception has been thrown by the …
Razor

ASP.NET MVC @Html.MenuLink for Bootstrap

Bootstrap是目前流行的前端装逼框架,可惜ASP.NET MVC没有现成的Razor HTML Helper来做导航栏按钮(链接),一个很常见的需求是导航栏按钮根据当前的controller,action加上高亮。 在bootstrap的HTML里定义如下: 我们自定义一个Helper就能生成这样的HTML: public static MvcHtmlString MenuLink(this HtmlHelper htmlHelper, string linkText, string actionName, string controllerName, string[] highlightedActionNames = null) { var currentAction = htmlHelper.ViewContext.RouteData. …
MVC Razor Bootstrap

ASP.NET中使用Razor导致自定义Membership失效的解决办法

最近在研究Razor和MVC,打算逐步把博客用Razor重写一边。今天一上手就碰到个蛋碎的问题。不管是在MVC应用程序,还是传统的WebForm项目中添加Razor页(既.cshtml类型的页面),就会导致自定义的Membership Provider失效。如果去掉Membership的配置则一切正常。 具体问题表现在有两个地方报错: 1. 运行时报错:Parser Error Message: Default Membership Provider could not be found. 2. 编译时报错:Error    58    The pre-application start initialization method Start on type System.Web.WebPages.Deployment.PreApplicationStartCode threw an …
Membership Razor Web.Config