Tag mvc

.NET MVC – Illegal characters in path

ScenarioRender a ASP.NET MVC Razor view with a model from the controller. Error / ExceptionSystem.ArgumentException: Illegal characters in path. CauseThe model from the controller was returning JSON and the view had declared “@model string” to handle the JSON. SolutionUpdates in…

Could not load file or assembly System.Web.WebPages.Razor

Suddenly got the error message when starting a MVC application: Could not load file or assembly ‘System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of its dependencies. The system cannot find the file specified. Description: An unhandled exception occurred during the execution…

Entity type is not part of the model for current context

The entity type <Type> is not part of the model for the current context. ExceptionType: System.InvalidOperationException System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) vid System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) vid System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() vid System.Web.Http.Controllers.ApiControllerActionInvoker.d__0.MoveNext() — Slut på stackspårningen från föregående plats där ett undantag utlöstes — vid System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)…

Local IIS failed to map the path ‘/’

Got an exception of System.InvalidOperationException: “Failed to map the path ‘/’” when starting the site on a local IIS. System.Web.HttpRuntime.HostingInit(HostingEnvironmentFlags hostingFlags, PolicyLevel policyLevel, Exception appDomainCreationException) +556 [HttpException (0x80004005): Det gick inte att mappa sökvägen /.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)…

Call stored procedure via DBContext

Tried to call a SP via Entity framework (DBContext) but got a exception that parameter is not supplied. My call looked like: context.Database.ExecuteSqlCommand(“NameOfSP”, new SqlParameter(“@param1”, 1), new SqlParameter(“@param2”, DateTime.Now), new SqlParameter(“@param3”, “test”)); The right call should look like: context.Database.ExecuteSqlCommand(“NameOfSP @p1,…