How can I use CSHTML (Razor) in ASPX WebForm projects?

0

I was taking a look at in this question in English Stackoverflow, because I really find it very confusing to use the ASPX files and I find the Razor syntax more friendly.

When trying to add a file with the extension .cshtml the project to test, I had a system error:

  

Could not determine which version of ASP.NET Web Pages to use.

     

In order to use this site, specify the version in the site's web.config file. For more information, see the following article on the Microsoft support site: link

     

[InvalidOperationException: Could not determine which version of   ASP.NET Web Pages to use.

     

In order to use this site, specify a version in the site's web.config   filet. For more information, see the following article on the Microsoft   support site: link
  System.Web.WebPages.Deployment.PreApplicationStartCode.StartCore (IFileSystem   fileSystem, String appDomainAppPath, String binDirectory,   NameValueCollection appSettings, IEnumerable 1 loadedAssemblies, IBuildManager buildManager, Action 1 loadWebPages, Action   registerForChangeNotification, Func'2 getAssemblyNameThunk) +16236
  System.Web.WebPages.Deployment.PreApplicationStartCode.StartCore ()   +167 System.Web.WebPages.Deployment.PreApplicationStartCode.Start () +38

     

[InvalidOperationException: The method of initializing   preload the Start application in type   System.Web.WebPages.Deployment.PreApplicationStartCode issued a   Exception with the following error message: Could not determine which   version of ASP.NET Web Pages to use.

     

In order to use this site, specify a version in the site's web.config   filet. For more information, see the following article on the Microsoft   support site: link
  System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore (ICollection 1 methods, Func 1 setHostingEnvironmentCultures) +615
  System.Web.Compilation.BuildManager.InvokePreStartInitMethods (ICollection'1   methods) +141
  System.Web.Compilation.BuildManager.CallPreStartInitMethods (String   preStartInitListPath, Boolean & isRefAssemblyLoaded) +102
  System.Web.Compilation.BuildManager.ExecutePreAppStart () +157
  System.Web.Hosting.HostingEnvironment.Initialize (ApplicationManager   appManager, IApplicationHost appHost, IConfigMapPathFactory   configMapPathFactory, HostingEnvironmentParameters hostingParameters,   PolicyLevel policyLevel, Exception appDomainCreationException) +549

     

[HttpException (0x80004005): The method of initializing the   preload the Start application in type   System.Web.WebPages.Deployment.PreApplicationStartCode issued a   Exception with the following error message: Could not determine which   version of ASP.NET Web Pages to use.

     

In order to use this site, specify a version in the site's web.config   filet. For more information, see the following article on the Microsoft   support site: link
  System.Web.HttpRuntime.FirstRequestInit (HttpContext context) +10085804   System.Web.HttpRuntime.EnsureFirstRequestInit (HttpContext context) +95   System.Web.HttpRuntime.ProcessRequestNotificationPrivate (IIS7WorkerRequest   wr, HttpContext context) +254

I would like to know if it is really possible to replace the ASPX files with CSHTML.

    
asked by anonymous 01.12.2017 / 12:43

0 answers