Hosting xamlx Workflow service in IIS 7.5 errors out - workflow-foundation-4

I created the most basic webservice using the Receive/SendReply with WWF 4 (.Net 4). I am not posting the code since the problem is related with deployment.
The documentation and therefore my expectation is that the xamlx file and web.config file along with the dll files have to be copied to the IIS application and bin folders, which I have done. The service works fine when launched via Visual Studio however when I copy the files to the IIS folder, it gives the following error.
HTTP Error 404.3 - Not Found
The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.
I have checked against the web.config provided in the WWF samples and find that they are the same, however I am posting the file here.
<compilation debug="true" targetFramework="4.0" />
</system.web>
<system.serviceModel>
<bindings />
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
</configuration>

Just expanding on Maurice's comment:
You should run aspnet_regiis.exe -i as an administrator.
I had this file in: C:\Windows\Microsoft.NET\Framework\v4.0.30319
After executing it (it took around 5 seconds) I had all the mappings needed for the workflow to run.

It sounds like you are missing the httpHandler for the workflows. Normally this is in your machine web.config.
<configuration>
<configSections>
<sectionGroup name="system.xaml.hosting"
type="System.Xaml.Hosting.Configuration.XamlHostingSectionGroup, System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="httpHandlers"
type="System.Xaml.Hosting.Configuration.XamlHostingSection, System.Xaml.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</sectionGroup>
</configSections>
<system.xaml.hosting>
<httpHandlers>
<add xamlRootElementType="System.ServiceModel.Activities.WorkflowService, System.ServiceModel.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
httpHandlerType="System.ServiceModel.Activities.Activation.ServiceModelActivitiesActivationHandlerAsync, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add xamlRootElementType="System.Activities.Activity, System.Activities, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
httpHandlerType="System.ServiceModel.Activities.Activation.ServiceModelActivitiesActivationHandlerAsync, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</httpHandlers>
</system.xaml.hosting>

Related

Can Azure Service Bus Relay be used to expose an ASP.NET hosted WCF service?

I'm working on a project where an ASP.NET WCF Service is hosted on-premises, and it needs to be exposed for use by other applications that are hosted in Microsoft Azure.
Azure Service Bus Relay is the desired method to expose the ASP.NET WCF service to the applications that are hosted within Azure. However, all the Azure documentation only show examples of setting up Service Bus Relay with a WCF service being hosted within a Console app.
Is it possible to host a WCF service within an ASP.NET application on IIS and have it exposed through Azure Service Bus Relay?
I think what you need is to set up an Azure Hybrid Connection which is built for the exact thing that you are trying to do:
Here is an intro:
https://azure.microsoft.com/en-us/documentation/articles/integration-hybrid-connection-overview/
Here is how to set it up:
https://azure.microsoft.com/en-us/documentation/articles/integration-hybrid-connection-create-manage/
Sidney Andrews posted an example at the following link of how to Configure the ASP.NET web.config file to setup the WCF service with the Service Bus Relay Endpoint.
https://gist.github.com/SidneyAndrewsOpsgility/bc1096ac96401f95b3d7
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.5.2"/>
<httpRuntime targetFramework="4.5.2"/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="ServiceBusBehavior">
<transportClientEndpointBehavior>
<tokenProvider>
<sharedAccessSignature keyName="RootManageSharedAccessKey" key="[replace with your key]" />
</tokenProvider>
</transportClientEndpointBehavior>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service name="WcfTest.Services.ClockService">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="DefaultBinding" contract="WcfTest.Services.IClockService"/>
<endpoint address="sb://[replace with your namespace].servicebus.windows.net/clock" binding="netTcpRelayBinding" behaviorConfiguration="ServiceBusBehavior" contract="WcfTest.Services.IClockService"/>
</service>
</services>
<bindings>
<basicHttpBinding>
<binding name="DefaultBinding" />
</basicHttpBinding>
<netTcpRelayBinding>
<binding name="ServiceBusBinding" />
</netTcpRelayBinding>
</bindings>
<extensions>
<!-- In this extension section we are introducing all known service bus extensions. User can remove the ones they don't need. -->
<behaviorExtensions>
<add name="connectionStatusBehavior"
type="Microsoft.ServiceBus.Configuration.ConnectionStatusElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="transportClientEndpointBehavior"
type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="serviceRegistrySettings"
type="Microsoft.ServiceBus.Configuration.ServiceRegistrySettingsElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</behaviorExtensions>
<bindingElementExtensions>
<add name="netMessagingTransport"
type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingTransportExtensionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="tcpRelayTransport"
type="Microsoft.ServiceBus.Configuration.TcpRelayTransportElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="httpRelayTransport"
type="Microsoft.ServiceBus.Configuration.HttpRelayTransportElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="httpsRelayTransport"
type="Microsoft.ServiceBus.Configuration.HttpsRelayTransportElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="onewayRelayTransport"
type="Microsoft.ServiceBus.Configuration.RelayedOnewayTransportElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</bindingElementExtensions>
<bindingExtensions>
<add name="basicHttpRelayBinding"
type="Microsoft.ServiceBus.Configuration.BasicHttpRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="webHttpRelayBinding"
type="Microsoft.ServiceBus.Configuration.WebHttpRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ws2007HttpRelayBinding"
type="Microsoft.ServiceBus.Configuration.WS2007HttpRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="netTcpRelayBinding"
type="Microsoft.ServiceBus.Configuration.NetTcpRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="netOnewayRelayBinding"
type="Microsoft.ServiceBus.Configuration.NetOnewayRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="netEventRelayBinding"
type="Microsoft.ServiceBus.Configuration.NetEventRelayBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="netMessagingBinding"
type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingBindingCollectionElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</bindingExtensions>
</extensions>
</system.serviceModel>
</configuration>
Thanks Sidney, this is exactly what I needed!

The name 'ViewBag' does not exist in the current context mvc 5

I have web.config inside the Views folder
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="PartyInvites" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
</appSettings>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
I also make sure the solutions Web.config is updated
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-5.2.2.0" newVersion="5.2.2.0"/>
</dependentAssembly>
But when i look at the views, i still get the error
Compiler Error Message: CS0103: The name 'Viewbag' does not exist in
the current context
Looks like my issue is an isolated case, VS tells me it get screwed after i updated some extension, i cannot remember what extension made it like this so i just repaired the installation of VS and it worked.
I had the same issue on Visual Studio 2015. It was resolved by updating the .Net Framework to use 4.5.2 instead of 4.0. This is done in the Properties page of the project.
I had this issue regardless of having all the correct configuration done in the web.config file.
Found out to be some bad files in the Component Cache, preventing the Razor views from recognising ViewBag, Model, and HtmlHelpers. Deleting these files solved the problem (good versions of these files were created next time I opened Visual Studio).
Please follow below path to discover the files:
C:\Users\your.name.here\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
Delete all four files:
Microsoft.VisualStudio.Default.cache
Microsoft.VisualStudio.Default.catalogs
Microsoft.VisualStudio.Default.err
Microsoft.VisualStudio.Default.external
I closed my project, deleted the files on that path and reopened my project, cleaned the solution and built it again and the problem was solved
Deleting your Temporary ASP.NET Files also helps. C:\Users\your.name.here\AppData\Local\Temp\Temporary ASP.NET Files.
Thanks!

same ScriptResource,axd loaded twice

Good Morning,
We have an existing application that is stable and error free on a Windows Server 2008R2 with IIS 7.5 / .NET 4.5.
We are planning a move to Windows Server 2012R2 with IIS 8.5 / .NET 4.5 and are now encountered the problem that the application (identical binaries / configuration) are indeed injected two ScriptResource.axd files, but both contain the same content (different URLs).
Because of this, the MicrosoftAjaxWebforms.js, which provides "Sys.WebForms" is missing and i'm getting the Error
Unable to get property 'PageRequestManager' of undefined or null reference
The problem is browser Independent on two independent virtual machines.
The application runs in classic mode, the web.config does not contain the < xhtmlConformance > tag.
There are all the latest server updates.
All other functionalities of the application are working properly.
I hope some of you encountered the same Problem and know the solution.
Greetings, Verni
EDITH:
Snippet of web.config (system.web section)
<system.web>
<httpRuntime requestValidationMode="2.0" requestPathInvalidCharacters="" targetFramework="4.5" enableVersionHeader="false" />
<sessionState timeout="30" mode="StateServer" stateConnectionString="tcpip=...:42424" />
<httpModules>
<add name="LinkPartnerModule" type="....LinkPartnerModule, ..." />
<add name="RedirectModule" type="....RedirectModule, ..." />
<add name="ScriptCompressorModule" type="ScriptCompressorModule, ..." />
</httpModules>
<httpHandlers>
<remove verb="*" path="scriptresource.axd"/> // added from StackOverflow
<add verb="*" path="*js.axd" type="ScriptCompressorHandler" />
</httpHandlers>
<compilation debug="false" defaultLanguage="c#" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Services.Client, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Services.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A" />
<add assembly="System.Speech, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<globalization culture="de-DE" enableClientBasedCulture="true" fileEncoding="utf-8" uiCulture="de" />
<pages compilationMode="Auto" styleSheetTheme="*" validateRequest="false" enableEventValidation="false" controlRenderingCompatibilityVersion="3.5" enableViewState="true" clientIDMode="AutoID">
</system.web>
<system.web.extensions>
<scripting>
<scriptResourceHandler enableCompression="true" enableCaching="true" />
</scripting>
</system.web.extensions>
We had this issue as well for an application running in classic mode. The issue that time turned out to be multiple httphandlers registered for the .axd extension.
If you in your web.config make sure to remove any .axd handler before adding them it might resolve your issue.
Something like:
<remove verb="*" path="scriptresource.axd"/>
Edit:
When looking at your web.config I'm pretty sure the problem is related to the scriptcompressorhandler and module. As you stated this only happens using HTTPS and I suspect that what happens is that the module still runs over HTTPS but the handler does not. This means that the module sends the compressed version over to the regular scriptresource handler and a new copy of the script is outputted.
The solution would be to either activate scriptcompressorhandler over HTTPS as well or make sure the module is not run over HTTPS.
I fixed the Problem.
The reason was an misconfigured ARR (Application Request Router),
where SSL-Offloading was active.
The main reason of misconfiguration was the "function" that activates SSL-Offloading if no URL-Rewrite Rule is there with name like 'ARR_farmName_loadbalance_SSL'.
If this Rule will be deleted, the manager activates SSL-Offloading automatically.
Thanks to Robban, who brought me to HTTPS / SSL.

Problem with Elmah in the GAC

I am attempting to follow this article:
http://www.codeproject.com/KB/aspnet/elmahGAC.aspx
to get Elmah working from the GAC rather than needing to be setup for each application individually. Everything works locally but when the settings are set globally, Elmah stops logging. I read somewhere that if Elmah is running from the GAC then the settings should be in the "global" machine.config vs the "global" web.config but I've tried both. Right now, I'm at a point where if I add this:
<system.webServer>
<modules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=abc123" preCondition="managedHandler" />
</modules>
</system.webServer>
into my application's web.config, it picks up the rest of the settings from the global machine.config and logs successfully. To answer the obvious question, yes I have this section in the global machine.config and have even tried entering it in the global web.config but still logging won't work. Anyone have any ideas? Is there anyway to get Elmah to display its errors instead of failing quietly?
EDIT: Here is my "global" machine.config file. It's just the default one with the stuff for ELMAH added and some section groups taken out to meet the char limit. I should probably also note this is running in IIS7.
<?xml version="1.0" encoding="UTF-8" ?>
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" />
</sectionGroup>
</configSections>
<connectionStrings>
<clear />
<add name="Elmah.Sql" connectionString="IMNOTTELLING" providerName="System.Data.SqlClient" />
<add name="LocalSqlServer" connectionString="IMNOTTELLING" providerName="System.Data.SqlClient" />
</connectionStrings>
<elmah>
<security allowRemoteAccess="0" />
<errorLog type="Elmah.SqlErrorLog, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" connectionStringName="Elmah.Sql" />
</elmah>
<runtime />
<system.data>
<DbProviderFactories />
</system.data>
<system.serviceModel>
Nothing tampered with here
</system.serviceModel>
<system.web>
<processModel autoConfig="true"/>
<httpHandlers>
<add verb="POST,GET,HEAD" path="elmah.axd" type="Elmah.ErrorLogPageFactory, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" />
</httpHandlers>
<httpModules>
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" />
</httpModules>
<compilation>
<assemblies>
<add assembly="Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" />
</assemblies>
</compilation>
<membership>
Nothing tampered with here
</membership>
<profile>
<providers>
<add name="AspNetSqlProfileProvider" connectionStringName="LocalSqlServer" applicationName="/"
type="System.Web.Profile.SqlProfileProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</providers>
</profile>
<roleManager>
Nothing tampered with here
</roleManager>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests ="true">
<add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" preCondition="managedHandler" />
<add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" preCondition="managedHandler" />
<add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" preCondition="managedHandler" />
</modules>
<handlers>
<add name="Elmah" path="elmah.axd" verb="POST,GET,HEAD" type="Elmah.ErrorLogPageFactory, Elmah, Version=1.2.13605.0, Culture=neutral, PublicKeyToken=e50dbdd41da277ac" preCondition="integratedMode" />
</handlers>
</system.webServer>
</configuration>
EDIT: I installed the modules and handler in IIS directly and now it works.
I also had problems with IIS7 on a Win7x64 install (testing for a production system). I finally got this working by putting the module and handler into the appropriate nodes in the applicationHost.config file.
C:\Windows\System32\inetsrv\config\applicationHost.config
It seems that IIS7 ignores certain areas of the main framework web.config files, instead using the applicationHost.config file for IIS settings.
Something to note about that file if you are on a 64 bit install: it seems that 32 bit applications (including Visual Studio) will appear to not see the file. It's because of some file system behavior due to the OS being 64 bit. One easy work around is to open it using an UNC path:
\\localhost\c$\Windows\System32\inetsrv\config\applicationHost.config
I really doubt the PublicKeyToken of Elmah is abc123... You need to use the real PublicKeyToken, which you can find if you look at the assembly in the GAC. It looks something like: b03f5f7f11d50a3a (that was for mscorlib.dll, so that is Microsoft's public key token).
EDIT: I installed the modules and handler in IIS directly and now it works.
I've tried everything I could find to get ELMAH working from the GAC on my Win7 Ultimate 64bit machine and the only thing that finally got it working was registering the elmah.axd handler and the various modules in IIS Manager.

"The name 'HTML' does not exist in the current context" in MVC 3 Views

I´m starting to use "MVC 3" but I´m facing some little problems. In my Views, when I code something like this:
#if(Request.IsAuthenticated) {
<text>Welcome <b>#Context.User.Identity.Name</b>!
[ #Html.ActionLink("Log Off", "LogOff", "Account") ]</text>
}
else {
#:[ #Html.ActionLink("Log On", "LogOn", "Account") ]
}
The objects like #Request and #Html is indicating an error: The name 'HTML' does not exist in the current context.
The same occurs with #Context, #ViewBag, #Layout, #Url and others.
See:
But the code is correctly compiled with no errors. The problem is that I cannot use the Intellisense with theses objects in the Views. Is it normal? (I don´t think so). What could be happening?
I have reinstalled the MVC 3 framework but the same still occurs.
Note: this is a new project from scratch, not a MVC 2 migration. This occurs both with Razor engine and ASPX.
This is the Web.Config in the Views folder:
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
Thanks!
You could try:
Close the View with the false errors.
(Steps 2-5 are sometimes optional) Close Visual Studio
Delete the bin and obj folders in all the Projects in the Solution.
Reopen the same Solution
Rebuild the Solution
Open a different View then the one causing the errors
Close that View, hopefully you didn't see any of the similar errors in this View
Reopen the View that gave you problems earlier
I have solved this issue with the old, good, wise Microsoft default solution: reinstall all the things again.
Uninstall and Reinstall the Visual Studio 2010 and MVC 3 Framework.
Clean your solution and Under references.
Then set the follow property:
System.Web.MVC file to Copy Local = True.
All I had to do was close all views that were open in the editor and rebuild.
What worked for me was closing Visual Studio, deleting the user option files (both solution and project level), then relaunching Visual Studio.
I'm using dotnet core sdk 2.2 and Visual Studio Professional 2019.
This was caused by Visual Studio mangling code.
Code was pasted into the razor view. Visual Studio would attempt but then fail to auto-format it. Part of the failure resulted in deleting code.
Pressing ctrl+z reverted the formatting but kept the pasted code. The razor compilation errors were then fixed (The name 'Html' does not exist in the current context)
Disable format on paste (see https://stackoverflow.com/a/28053865/1462295 ) under Tools -> Options -> Text Editor -> HTML -> Advanced
For me this just seemed to be the fact that I had compiler warnings. Code would still compile and run ok but it was not until I fixed all the build warnings that my Intellisense starting working.
I tried to remove the project that is still in trouble from solution and add it back again, after which the problem had been gone.
Set the property of System.Web.MVC,Copy Local = True
In my case my Packages folder was missing including MVC and Razor so I have updated packages in packages.config, reopened the view and it worked.
All you need to do is Restart Visual Studio and check.
You could try some following point:
Close the View with the false errors.
Close visual studio.
open project again.
clean your solution
Rebuild your solution.
hopefully you will not get any of the similar errors now.
If you still have same problem. than Please check following steps.
Make sure you have web.config file inside view folder. Becuase MVC has two web.config. one for solution and other one for project.
Your web.config file will seems like this which is inside views folder.
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Optimization"/>
<add namespace="System.Web.Routing" />
<add namespace="Your Project Name" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.webServer>
<handlers>
<remove name="BlockViewHandler"/>
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
<system.web>
<compilation>
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.7.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
</configuration>
It worked for me. and hope for you also.
Close Visual Studio => Delete the obj and bin folders located in your project => Start Visual Studio
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
solution for this problem in web.config
I experienced this on ASP.NET MVC 4 as well, after uninstalling EntityFramework from my packages list.
I had to remove this section
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, ....
that's left on the Web.config file... at the least it removed the errors from the errors list
Apologies for the necro post.
Selecting "Build | Rebuild Solution" corrected this issue for me in Visual Studio 2015. In my case, the warnings occurred after renaming the primary namespace of a project. A rebuild set everything straight.
I'm using ASP .net core. Solved mine by upgrading Microsoft.AspNetCore.Mvc from 1.1.2 to 1.1.3.
For me, I just restarted my Visual Studios and everything got fixed.
Maybe I am a bit late to answer this question but this easy fix helped me:
Right click the file > Exclude from project.
Right click the file > Include in project.
I had this same issue in MVC 4. None of these solutions worked for me. Instead, in Windows, I went into Control Panel -> Uninstall a program. Select Microsoft ASP.NET MVC 4 in the program list. Click 'Uninstall.' A 'Microsoft ASP.NET MVC 4 Setup' wizard will display. Click 'Repair.'

Resources