Is there a way to use CSHTML (Razor) in ASPX Webform projects?

Asked

Viewed 131 times

0

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

When trying to add a file with the extension .cshtml the project to make tests, I had an error in the system:

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 file. For more information, see the following article on the Microsoft support site: http://go.microsoft.com/fwlink/? Linkid=254126

[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 file. For more information, see the following article on the Microsoft support site: http://go.microsoft.com/fwlink/? Linkid=254126]
System.Web.Webpages.Deployment.Preapplicationstartcode.Startcore(Ifilesystem filesystem, String appDomainAppPath, String bindirectory, Namevaluecollection appSettings, Ienumerable1 loadedAssemblies, IBuildManager buildManager, Action1 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 initialization of the Start application preload on 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 file. For more information, see the following article on the Microsoft support site: http://go.microsoft.com/fwlink/? Linkid=254126.]
System.Web.Compilation.BuildManager.Invokeprestartinitmethodscore(Icollection1 methods, Func1 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 boot method of Start application preload on 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 file. For more information, see the following article on the Microsoft support site: http://go.microsoft.com/fwlink/? Linkid=254126.]
System.Web.Httpruntime.Firstrequestinit(Httpcontext context) +10085804 System.Web.Httpruntime.Ensurefirstrequestinit(Httpcontext context) +95 System.Web.Httpruntime.Processrequestnotificationprivate(Iis7workerrequest Wr, Httpcontext context) +254

I wonder if it is really possible to replace the files ASPX by CSHTML.

  • 1

    I think it’s like using a . Vb and trying to compile as . Cs

  • briefly not .... different things, do different and have different proposals.

  • I put <add key="webPages:Version" value="2.0"/> and the project is working now. And displaying the content...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.