I am having an issue with properly configuring ValidatingIssuerNameRegistry in my ASP.NET Web Application. According to this article, I configured Azure AD sign-on to my app. Everything appears to work fine, but Visual Studio 2013 gives me a config warning (blue underline) on the configuration section for trustedIssuers so I decided to find a fix. This gentleman describes an alternative way of doing it that lines up with the VS2013 config warning. But alas, it does not work for me. IIS Express gives me an error when I try to run it.
Any thoughts on what I have mixed up? I'm guessing there is a version issue with .NET 4.5/4.0 or something of that nature but I can't find it.
This does not work...
(Server Error: WIF10112: The only supported element inside 'issuerNameRegistry' is 'authority'. Found element 'trustedIssuers'.) NOTE: Bottom of error page reports:
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34009
<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<trustedIssuers>
<add name="[MYNAME]" thumbprint="[MYTHUMB]"/>
</trustedIssuers>
</issuerNameRegistry>
This does work, but gives a compile time warning (expected 'trustedIssuers')...
<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<authority name="MYNAME">
<keys>
<add thumbprint="MYTHUMB" />
</keys>
<validIssuers>
<add name="MYNAME" />
</validIssuers>
</authority>
</issuerNameRegistry>
Visual Studio uses XSD schemas to validate the config as far as I am aware. They usually reside in a folder like C:\Program Files (x86)\Microsoft Visual Studio 11.0\Xml\Schemas
The schema for the ValidatingIssuerNameRegistry is (http://msdn.microsoft.com/en-us/library/system.identitymodel.tokens.validatingissuernameregistry(v=vs.115).aspx):
<system.identityModel>
<issuerNameRegistry type='derived from ValidatingIssuerNameRegistry'>
<authority name='someFriendlyName'>
<keys>
<add thumbprint='caseInsensitiveString'/>
<add symmetricKey='Base64Encoded bytes' />
</keys>
<validIssuers>
<add name='issuer1'/>
<add name='issuer2'/>
</validIssuers>
</authority>
</issuerNameRegistry>
</system.identityModel>
The schema for the ConfigurationBasedIssuerNameRegistry is (http://msdn.microsoft.com/en-us/library/system.identitymodel.tokens.configurationbasedissuernameregistry(v=vs.110).aspx):
<system.identityModel>
<identityConfiguration>
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel">
<trustedIssuers>
<add thumbprint="thumbprint" name="name" />
</trustedIssuers>
</issuerNameRegistry>
</identityConfiguration>
It is likely the XSD files that visual studio uses only reference one or the other. The easiest way to find it is to search the XSD files for the string vs:help="configuration/system.identityModel/issuerNameRegistry"
You can update the schema if you wish so you no longer get the blue underlined text. I'm only using Visual Studio 2012 so I can't confirm this will work for you.
I think I figured out the issue but I'm not sure why. For some reason, the system must be picking up a previous version of "System.IdentityModel.Tokens.ValidatingIssuerNameRegistry". If you can explain why, I'll be happy to mark you as answer.
<issuerNameRegistry type="System.IdentityModel.Tokens.ValidatingIssuerNameRegistry, System.IdentityModel.Tokens.ValidatingIssuerNameRegistry">
<trustedIssuers>
<add name="[MYNAME]" thumbprint="[MYTHUMB]"/>
</trustedIssuers>
</issuerNameRegistry>
Should Be...
<issuerNameRegistry type="System.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<trustedIssuers>
<add name="[MYNAME]" thumbprint="[MYTHUMB]"/>
</trustedIssuers>
</issuerNameRegistry>
Related
I'm trying to build an ASP.NET web site for Microsoft .NET 4.0 using Entity Framework 6. The website is explicitly targetting .NET 4.0 in web.config:
<compilation debug="true" targetFramework="4.0">
, IIS Express' application pool in applicationhost.config also targets .NET 4.0:
<add name="Clr4ClassicAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />
When the site is launched, a number of CS0433 compiler errors is shown, ones like below:
error CS0433: The type "System.ComponentModel.DataAnnotations.Schema.TableAttribute" exists in both "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" and "c:\Users\%username%\AppData\Local\Temp\Temporary ASP.NET Files\vs\e798ee36\2b3f5a24\assembly\dl3\fd34a92a\0052703a_0990d101\EntityFramework.DLL"
As far as I remember, there should be no System.ComponentModel.DataAnnotations assembly in .NET 4.0, or at the very least it shouldn't contain classes like TableAttribute, KeyAttribute etc. The only lead I have is the bottom line of error page, which says
Microsoft .NET Framework, version:4.0.30319; ASP.NET, version:4.6.1055.0
however, I don't know how to change specifically ASP.NET version for a website (of course, if that's the problem's source).
Have you tried setting the compilation batch to false?
<compilation debug="false" batch="false">
I'm assuming you've got code in your App_Code folder (likely your Entity Framework classes at the least?).
Now you could move your code out of there, and precompile everything so that you deploy the website assembly and not any source files.
Otherwise, you really need to look at your projects and ensure that nothing is referencing System.ComponentModel.DataAnnotations.
Also, check any web.config in the project at the root, or in the App_Code folder(s) and make sure there is no
<add assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
under system.web/compilation/assemblies. If there isn't, you could even try putting in
<remove assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
e.g.:
<compilation>
<assemblies>
<remove assembly="System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
You can also check to make sure it's running the earlier version of ASP.NET so that it picks up the version of the DataAnnotations assembly that doesn't have the Schema attribute (as the 4.5+ framework version does):
<configuration>
<system.web>
<httpRuntime targetFramework="4.0" />
</system.web>
</configuration>
Hey Can you check your project.Please check there should not be two model with same properties.Model can also be entity framework class model
Check if all NuGet packages for your project are updated or if there are any installed that you don't want.
How does one go about transforming the audienceUris and federatedAuthentication elements in the microsoft.identitymodel configuration section using the standard visual studio web.config transforms?
For the development environment, we have all the subdomains postfixed with a '-dev' along with special localhost port numbers, for example: realm="https://client-dev.domain.com:444". Today the main web.config reflects this but ideally we would like to move this setting to Web.Debug.config and in the Web.Release.config we would like to specify the proper audience and realms sans the '-dev' postfix and the local port settings. However, attempting to put xdt:Transform="Replace" in the microsoft.identitymodel element inside the Web.Debug.Config results in this warning:
The 'http://schemas.microsoft.com/XML-Document-Transform:transform' attribute is not declared.
and of course runtime failures (not being able to find servicecertificate for example).
Here's the microsoft.identitymodel sections:
<configuration>
<configSections>
<section name="microsoft.identityModel" type="Microsoft.IdentityModel.Configuration.MicrosoftIdentityModelSection, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<microsoft.identityModel>
<service>
<applicationService>
<claimTypeRequired>
<claimType type="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/privatepersonalidentifier" optional="false" />
<claimType type="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress" optional="false" />
</claimTypeRequired>
</applicationService>
<serviceCertificate>
<certificateReference x509FindType="FindByThumbprint" findValue="NNNNNNNNNN" storeLocation="LocalMachine" storeName="My" />
</serviceCertificate>
<certificateValidation certificateValidationMode="None" />
<audienceUris>
<add value="https://url/" />
</audienceUris>
<federatedAuthentication>
<wsFederation passiveRedirectEnabled="true" issuer="https://url/" realm="https://url/" requireHttps="true" />
<cookieHandler requireSsl="true" />
</federatedAuthentication>
<issuerNameRegistry type="Microsoft.IdentityModel.Tokens.ConfigurationBasedIssuerNameRegistry, Microsoft.IdentityModel, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<trustedIssuers>
<add thumbprint="NNNNNNNNNN" name="https://url/" />
</trustedIssuers>
</issuerNameRegistry>
</service>
</microsoft.identityModel>
<configuration>
Existing solutions that don't work:
1) Same issue was raised here but no proper response. The RemoveAll and Insert doesn't work:
Web config transform on microsoft.identityModel - 'http://schemas.microsoft.com/XML-Document-Transform' attribute is not declared
2) Also, tried to manipulate the namespace as suggested on this thread and this doesn't work either:
http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/9ededb66-3e34-4bba-8e20-a2cc6025f0f9
3) configSource looked promising but again does work when specified in the microsoft.identitymodel element.
I get:
Warning 1 The 'configSource' attribute is not declared.
http://blog.andreloker.de/post/2008/06/16/Keep-your-config-clean-with-external-config-files.aspx
Any help will be appreciated! Thanks.
After a lot of trial and error, I resorted to using XMLPreProcess by Loren Halvorson to auto-generate the correct Web.config from a TemplateWeb.config as part of the pre-Build event for each project.
Although I would have liked Visual Studio's attempt at this to work for developers, alas, time is of money and its time for me to move on. Needless to say, it's broken in the SQL Azure SDK as well because the transforms only occured when you publish a site. In the latest Azure SDK, that is no longer the case and hence transforms stopped working as well. Oh joy!
Here's a link to the excellent tool, I think, a must-have for every ASP.NET developer:
http://xmlpreprocess.codeplex.com/
I receive this error when I view an application.
HTTP Error 500.22 - Internal Server Error (An ASP.NET setting has been detected that does not apply in Integrated managed pipeline mode.)
.Net framework 2.0, 3.5 and 4 are installed and I am using SQL 2008. Can anyone tell me what the solution is for this error?
This issue is caused by the pipeline mode in your Application Pool setting that your web site is set to.
Short
Simple way Change the Application Pool mode to one that has Classic pipeline enabled.
Correct way Your web.config / web app will need to be altered to support Integrated pipelines. Normally this is as simple as removing parts of your web.config.
Simple way (bad practice) Add the following to your web.config. See http://www.iis.net/ConfigReference/system.webServer/validation
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
</system.webServer>
Long
If possible, your best bet is to change your application to support the integrated pipelines. There are a number of changes between IIS6 and IIS7.x that will cause this error. You can find details about these changes here http://learn.iis.net/page.aspx/381/aspnet-20-breaking-changes-on-iis-70/.
If you're unable to do that, you'll need to change the App pool which may be more difficult to do depending on your availability to the web server.
Go to the web server
Open the IIS Manager
Navigate to your site
Click Advanced Settings on the right Action pane
Under Application Pool, change it to an app pool that has classic enabled.
Check http://technet.microsoft.com/en-us/library/cc731755(WS.10).aspx for details on changing the App Pool
If you need to create an App Pool with Classic pipelines, take a look at http://technet.microsoft.com/en-us/library/cc731784(WS.10).aspx
If you don't have access to the server to make this change, you'll need to do this through your hosting server and contact them for help.
Feel free to ask questions.
In your web.config, make sure these keys exist:
<configuration>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
</system.webServer>
</configuration>
I changed my web.config file to use HTTPMODULE in two forms:
IIS: 6
<httpModules>
<add name="Module" type="app.Module,app"/>
</httpModules>
IIS: 7.5
<system.webServer>
<modules>
<add name="Module" type="app.Module,app"/>
</modules>
</system.webServer>
Using VS2013 .net 4.5
I had this same issue.
The "Most likely causes" section on the error message page provided the most help. For me. It said "This application defines configuration in the system.web/httpModules section." Then in the "Things you can try" section it said "Migrate the configuration to the system.webServer/modules section."
<system.web>
<httpHandlers>
<add type="DevExpress.Web.ASPxUploadProgressHttpHandler, DevExpress.Web.v15.1, Version=15.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="ASPxUploadProgressHandlerPage.ashx" validate="false" />
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.1, Version=15.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET" path="DX.ashx" validate="false" />
</httpHandlers>
<httpModules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.1, Version=15.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</httpModules>
</system.web>
into the system.webServer section.
<system.webServer>
<handlers>
<add type="DevExpress.Web.ASPxUploadProgressHttpHandler, DevExpress.Web.v15.1, Version=15.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET,POST" path="ASPxUploadProgressHandlerPage.ashx" name="ASPxUploadProgressHandler" preCondition="integratedMode" />
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.1, Version=15.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" verb="GET" path="DX.ashx" name="ASPxHttpHandlerModule" preCondition="integratedMode" />
</handlers>
<modules>
<add type="DevExpress.Web.ASPxHttpHandlerModule, DevExpress.Web.v15.1, Version=15.1.4.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" name="ASPxHttpHandlerModule" />
</modules>
</system.webServer>
This worked for me:
Delete the originally created site.
Recreate the site in IIS
Clean solution
Build solution
Seems like something went south when I originally created the site. I hate solutions that are similar to "Restart your machine, then reinstall windows" without knowing what caused the error. But, this worked for me. Quick and simple. Hope it helps someone else.
I have a similar problem with IIS 7, Win 7 Enterprise Pack. I have changed the application Pool as in #Kirk answer :
Change the Application Pool mode to one that has Classic pipeline enabled".but no luck for me.
Adding one more step worked for me.
I have changed the my website's .NET Frameworkis v2.0 to .NET Frameworkis v4.0. in ApplicationPool
Personnaly I encountered this issue while migrating a IIS6 website into IIS7, in order to fix this issue I used this command line :
%windir%\System32\inetsrv\appcmd migrate config "MyWebSite\"
Make sure to backup your web.config
Set Application pool to classic .NET appool and make sure that Classic .Net apppool working on Classic managed piple line .
I've run into a problem with WCF REST Service. I get:
Could not load type 'System.ServiceModel.Activation.HttpHandler' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
when running inside of the IIS in an ASP.NET 4.0 AppPool.
The problem seems to occur only if:
Running inside of IIS
When ASP.NET Comaptibility is enabled
Running in Cassini - no problem it works properly. Running with ASP.NET compatibility off - no problem it works.
It appears that it's some sort of handler version conflict trying to instantiate the wrong version of the handler that in turn tries to load an older version of System.ServiceModel, but I haven't been able to trace this down.
Anybody seen anything like this before and have any ideas how to track this down further?
I've looked in ApplicationHost.config and the master web.config files for System.ServiceModel and HttpHandler references but no luck. There.
+++ Rick ---
fire up your Visual Studio 2010 Command Prompt or browse to "C:\Windows\Microsoft.NET\Framework\ v4.0.30319". And run the following command from the command prompt:
aspnet_regiis.exe -iru
This will register latest .net version. Also make sure your app pool is running latest version of .net
So as expected this turned out to be a versioning conflict in the default handler mappings in ApplicationHost.config. Specifically IIS has mappings for ASP.NET 2.0 and ASP.NET 4.0 specific references to the service activation handler (and module) and the 2.0 references weren't restricted by a version specific preCondition.
To fix the above problem I had to change (at the System root in ApplicationHost.config):
<add name="svc-Integrated" path="*.svc" verb="*"
type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
preCondition="integratedMode" />
to:
<add name="svc-Integrated" path="*.svc" verb="*"
type="System.ServiceModel.Activation.HttpHandler, System.ServiceModel, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089"
preCondition="integratedMode,runtimeVersionv2.0" />
Note the EXPLICIT runtimeVersion2.0. There are additional *.svc maps in the same section for the runtimeVersion4.0 which then fire the appropriate runtimes.
According to Microsoft this situation can arise when some older tools (I'm guessing Azure tools???) are installed that don't register the runtime version properly.
Problem solved.
There is one more way if all of above doesn't work. (Strange)
We were using Windows Server 2008 R2 SP1 with IIS 7.5.7600
After registering latest framework as given in above answer,
You need to the add handler mapping to v.4.0 assembly manually to web.config and remove "ServiceModel" from Modules.
<system.webServer>
<handlers>
<remove name="svc-Integrated" />
<add name=".svc" verb="*" path="*.svc" type="System.ServiceModel.Activation.ServiceHttpHandlerFactory,
System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</handlers>
<modules>
<remove name="ServiceModel" />
</modules>
</system.webServer>
More here
When the following profile section is in my web.config, the first page request fail with FileNotFoundException and a bunch of error coming from the compiler (from the look of the stack trace). When the properties section is removed, everything works again (until I try to reference something from the Profile of course). The rest of the website is pre-compiled, assembly per page, not-updatable.
The problem has only been reproduced on one machine-- the same build worked on other highly similar machines.
Am I missing anything obvious?
<profile>
<providers>
<clear />
<add name="AspNetSqlProfileProvider"
connectionStringName="ConnectionString"
applicationName="OIWebApps"
type="System.Web.Profile.SqlProfileProvider"/>
</providers>
<properties>
<group name="UI">
<add name="MasterPage" defaultValue="Horizontal.master"/>
<add name="Theme" defaultValue="Default"/>
<add name="IsSessionWarningEnabled" defaultValue="True" type="System.Boolean"/>
<add name="UseTelerikMultilineTextBoxes" defaultValue="True" type="System.Boolean"/>
<add name="FontSize" defaultValue="Smaller" type="System.String"/>
</group>
</properties>
</profile>
I see "UseTelereikMultilineTextBoxes". Could it be that a file needed for Telerik is missing on this machine?
It failed to compile because of a missing native .dll It was extremely hard to identify because the page that was executing didn't directly use the .net dll that depended on the missing native .dll, and even more confusingly, only some pages raised the compile error instead of being raised on all pages.