I have an asp.net application that moves or moves slowly in mvc, but when accessed via routing http://localhost:9490/razor
I get Type 'ASP._Page_Views_diagnostics_razor_cshtml' does not inherit from 'System.Web.UI.Page'.
Exception Details: System.Web.HttpException: Type 'ASP._Page_Views_diagnostics_razor_cshtml' does not inherit from 'System.Web.UI.Page'.
[HttpException (0x80004005): Type 'ASP._Page_Views_diagnostics_razor_cshtml' does not inherit from 'System.Web.UI.Page'.] System.Web.UI.Util.CheckAssignableType(Type baseType, Type type) +8864436 System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp) +75 System.Web.Routing.PageRouteHandler.GetHttpHandler(RequestContext requestContext) +138 System.Web.Routing.UrlRoutingModule.PostResolveRequestCache(HttpContextBase context) +8911880 System.Web.Routing.UrlRoutingModule.OnApplicationPostResolveRequestCache(Object sender, EventArgs e) +86 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75
When accessed almost directly (without .cshtml)
http://localhost:9490/views/diagnostics/razor
this happened before I added the views or controllers folder to the project. previously it was Pages/Diagnostics/razor with routes.MapPageRoute(null, "razor", "~/Pages/Diagnostics/razor.cshtml");
Route configuration - routes.MapPageRoute(null, "razor", "~/Views/diagnostics/razor.cshtml");
It works great. the page itself is pure html outside of a single variable access to confirm the razor code on the server side.
@{ Layout = null; Page.Title = "Razor test"; } <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <p>Razor rendering success</p> <p> [email protected] </p> </body> </html>
source share