Could not load file or assembly ‘WebMatrix.Data`
Go into: Tools > NuGet Package Manager > Package Manager Console And run the following command: PM> Install-Package Microsoft.AspNet.WebPages.Data
Go into: Tools > NuGet Package Manager > Package Manager Console And run the following command: PM> Install-Package Microsoft.AspNet.WebPages.Data
The simplest approach is to have 2 different presentation Projects only for Authentication/Authorization. This has the advantage of leaning on existing framework and standard configuration. From there, you decide to either create an AD user for every internet user, or create a DB/Internet user for every AD user. Creating an Identity user for each AD … Read more
Maybe you should try to have your enums as integers instead? This is how I did it public enum ECacheType { cache=1, none=2 } public enum EFileType { t1=1, t2=2 } public class TestController { [Route(“{type}/{library}/{version}/{file?}/{renew?}”)] public ActionResult Index2(EFileType type, string library, string version, string file = null, ECacheType renew = ECacheType.cache) { return View(“Index”); … Read more
ActionResult is an abstract class that an action can return. The helper methods in Controller (eg, Json(), Content(), View(), …) return different concrete classes that inherit ActionResult, including JsonResult. You should declare your action methods as returning ActionResult, so that they have the freedom to return any concrete result class.
We just had this error in one of our test environments. The problem was in the web.config file. The section had settings to reference the DotNetCompilerPlatform assembly, but had the wrong version number. We updated web.config to the proper version number and it fixed the error. <compilers> <compiler language=”c#;cs;csharp” extension=”.cs” type=”Microsoft.CodeDom.Providers.DotNetCompilerPlatform.CSharpCodeProvider, Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35″ … Read more
You can do like this public class SomeMsgAttribute : FilterAttribute, IResultFilter { public void OnResultExecuted(ResultExecutedContext filterContext) { } public void OnResultExecuting(ResultExecutingContext filterContext) { filterContext.Controller.ViewBag.Msg= “Hello”; } } Using: [SomeMsg] public ActionResult Index() { return View(); }
The best way is using Global.Asax, because you can manage all types of errors (Ajax calls/ all of unexpected Errors). with others you can’t do it. Like this: protected void Application_Error() { HttpContext httpContext = HttpContext.Current; if (httpContext != null) { RequestContext requestContext = ((MvcHandler)httpContext.CurrentHandler).RequestContext; /* When the request is ajax the system can automatically … Read more
So, based on my EDIT, I’ve modified my _Layout.cshtml so that instead of having @if(User.IsInRole(“Admin”)) {…} I have @if(User.Identity.IsAuthenticated && User.IsInRole(“Admin”)) {…} which seems to solve the problem. I believe the problem was that ASP .NET Identity uses an empty WindowsIdentity when no user is authenticated and when I try to check for the User.IsInRole, … Read more
These settings are used for dynamic compilation. They can be safely removed from the web.config if you do pre-compilation and only put the compiled assemblies on the webserver. See also The impact of multiple compiler definitions in system.codedom in web.config
I think I’ve figured it out. I believe the Razor viewengine is adhering to the HTML 5 way of setting boolean attributes, as described here: What does it mean in HTML 5 when an attribute is a boolean attribute? In HTML 5, a bool attribute is set like this: <input readonly /> or <input readonly=”readonly” … Read more