随笔分类 - ASP.NET & MVC
摘要:发一个无语的问题!View下的MasterPage ,断点可以看到 RouteData 但 取不到,错误1“System.Web.Routing.UrlRoutingModule.RequestData”不可访问,因为它受保护级别限。不能不说是一个设计缺陷!那位有高招,请不吝赐教~!汗!
阅读全文
摘要:原理自己写了一个ThemeController继承于Controller,先看我的文件结构:ThemeController的具体实现:[代码]调用方法:[代码]显示效果:自己觉得这是一个比较粗浅的解决方案,算是抛砖引玉吧,敬请多多拍砖!附上源码!更好的解决方案:重写视图引擎 附上源代码
阅读全文
摘要:问题重现: 当项目下:Controller/HomeController.cs时, 人在创建一个域Test,之后在建一个同名的HomeController: Areas/Test/Controller/HomeController.cs运行报错:Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{controller}/{action}/{id}/') does no
阅读全文
摘要:通过重写IAuthorizationFilter检查访问者是否授权,如果未授权就转到指定登陆页面去。代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--publicvoidOnAuthorization(AuthorizationContextfilt...
阅读全文
摘要:大多数情况下我们返回到客户端的Json有两种方式:1、直接传对象给Json()去转成Json代码Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--publicActionResultJsonTest(){List<Result>list=ne...
阅读全文