I have a problem deploying a MVC3 project IIS server, the project runs well in my local machine, but not in the server the errors say's this
Parser Error Message: The supplied credential is invalid.
This is the line of configuration of my merbership Provider
<add name="MembershipADProvider" type="System.Web.Security.ActiveDirectoryMembershipProvider, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" applicationName="AtentoCNEHoraExtra" connectionStringName="ADConnectionString" attributeMapUsername="sAMAccountName" />
What could be wrong???
I found the solution to my problem, I have to modify the identity of the process model associated with the pool .NET 4 in the configuration on my IIS
The value that has by default was ApplicationPoolIdentity and I have to changed to NetworkService
This configuration can be made in ISS --> Application Pool ----> .Net 4---> Advanced Settings --> Process Model
I hope that helps to others
Related
I have a legacy WebForms application. I need to add Azure B2C authentication to it. My application is using currently Microsoft.Aspnet.Identity. It does not have any startup.cs page. How can I make this migration?
Some minor things allow you to switch your site to use AAD or aadb2c for authentication.
Get the necessary OWIN NuGet packages, Add some startup code to use the OWIN authentication libraries ,Register your application in AADb2c.
Update your web.config with appropriate OAuth values.
Even though OWIN didn’t exist when you wrote your Web Forms app, you can still use it and it will significantly simplify the process.
In the Visual Studio menu, select Tools > NuGet Package Manager > Package Manager Console.
Make sure your web project is selected in the Default project drop down.
Run the below commands:
install-package Microsoft.Owin.Host.SystemWeb
install-package Microsoft.Owin.Security.OpenIdConnect
install-package Microsoft.Owin.Security.Cookies
You may check the references and then follow this B2C-WebForms-DotNet
References:
c# - ASP.NET Web Api - Startup.cs doesn't exist - Stack
Overflow
c# - OWIN Startup Class Missing - Stack Overflow
edit:
My web forms if for visual C# and could find owin start up :
Right click on App_Start > add item > under web , you can find it.
Please check if your project is visual c# .
edit 2:
Please check if below points help :
Maybe you can create new start up class by using owin library in the clas
Imports Microsoft.Owin.Extensions
Imports Microsoft.Owin.Security
Imports Microsoft.Owin.Security.Cookies
Imports Microsoft.Owin.Security.OpenIdConnect
Imports Owin
Imports System
Imports System.Configuration
Check the web.config file and remove this key setting and try
<add key="owin:AutomaticAppStartup" value="false" />
and also try add <add key="owin:AutomaticAppStartup" value="true " /> in web.config file
The following attribute will set the startup class to the StartUp class in the StartupDemo namespace.
[assembly: OwinStartup(typeof(StartupDemo.StartUp))]
Add appSetting element in the Configuration file
<appSettings>
<add key="owin:appStartup" value="StartupDemo.StartUp" />
</appSettings>
Check how owin detects start up owin-startup-class-detection -Microsoft docs
Other references:
owin-startup-class-not-detected
owin-with-vb-net-legacy-code-asp-net-web-forms
where-to-implement-startup-code-in-vb-net
I'm trying to get the sample MVC application from Kentor AuthServices deployed to Azure and using Okta as the IDP. I've jumped a few hurdles but have stumbled on the CryptographicException "The data protection operation was unsuccessful". I'm unsure how to resolve it.
When this occurs the URL in the browser is https://mysite.azurewebsites.net/AuthServices/Acs
Any assistance is appreciated, thanks.
Below is the kentor section of my web.config. I don't have an identity server so removed all the federation config..
<kentor.authServices entityId="https://mysite.azurewebsites.net/AuthServices"
returnUrl="https://mysite.azurewebsites.net/"
authenticateRequestSigningBehavior="Never">
<identityProviders>
<add entityId="http://www.okta.com/1111111"
allowUnsolicitedAuthnResponse="true" binding="HttpRedirect"
metadataLocation="https://dev-11111.oktapreview.com/app/1111111/sso/saml/metadata"
loadMetadata="true">
<signingCertificate fileName="~/App_Data/okta.cert" />
</add>
</identityProviders>
Let me know if I can provide any further info to assist you in assisting me!
It was actually an Azure issue as Anders points out. The fix was to add the following to web.config:
<system.identityModel>
<identityConfiguration>
<securityTokenHandlers>
<add type="System.IdentityModel.Services.Tokens.MachineKeySessionSecurityTokenHandler, System.IdentityModel.Services, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<remove type="System.IdentityModel.Tokens.SessionSecurityTokenHandler, System.IdentityModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</securityTokenHandlers>
</identityConfiguration>
</system.identityModel>
Looks like a bug in Kentor.AuthServices. I've recently done some rewriting which makes use of data protection API so something might be wrong there. Please file an issue at the github site and include the stack trace of the exception as well as information on what API module you are using (MVC, HttpModule or OWIN).
I am using Simplemembership in my asp.net web api project. When i try to validate the user using the below code, i get the error(Error 1)
if (!Membership.ValidateUser(username, password))
{
throw new ValidationException("Username or pwassword is incorrect.");
}
Error 1:
Attempt by security transparent method
'WebMatrix.WebData.SimpleMembershipProvider.
ValidateUser(System.String, System.String)' to access security
critical method
'System.Web.WebPages.StringExtensions.IsEmpty(System.String)' failed.
Earlier i got a similar error(Error 2) which i resolved by installing these packages:
Install-Package Microsoft.AspNet.WebHelpers
Install-Package Microsoft.AspNet.WebPages.Data
Error 2:
Attempt by security transparent method
'WebMatrix.WebData.PreApplicationStartCode.OnConnectionOpened(
System.Object, WebMatrix.Data.ConnectionEventArgs)' to access security
critical method 'System.Web.WebPages.
HttpContextExtensions.RegisterForDispose(System.Web.HttpContextBase,
System.IDisposable)' failed.
I did clean the solution and tried, still getting the same error,
Do i need to install any more packages or does even the simplemembership work in web api?
The current fix for me was by upgrading to .Net 4.5.3. I figured this out of frustration. This issue doesnt just affect MVC 5 but core Webmatrix projects as well after upgrading to webpages 3.2.3. I think it is a framework issue that will be fixed with the new Microsoft Identity. The current fix for me is below:
Note: Please use the property pages wizard in visual studio to change your target framework to .Net Framework 4.5.3. It will update your web.config
<compilation debug="true" targetFramework="4.5.3">
<assemblies>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</assemblies>
</compilation>
Step 1: Install-Package Microsoft.AspNet.WebHelpers
Step 2: Install-Package Microsoft.AspNet.WebPages.Data
Step 3: [Optional] Install-Package Owin
Step 4: Change targetFramework to .Net 4.5.3 via Property pages dialog box
I'm troubleshooting a WCF problem in our application, and turned on WCF tracing with the WCF Service Configuration Editor in VS 2010, which added the following sharedListener to the web.config:
<sharedListeners>
<add initializeData="D:\Logs\CRCCustomerService\Web_tracelog.svclog"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
Now, when I take steps to reproduce my error, I'm getting an exception thrown from the System.Diagostics library saying that it can't find XmlWriterTraceListener:
Stack Trace:
System.TypeInitializationException: The type initializer for 'System.ServiceModel.DiagnosticUtility' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Couldn't find type for class System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
at System.Diagnostics.TraceUtils.GetRuntimeObject(String className, Type baseType, String initializeData)
at System.Diagnostics.TypedElement.BaseGetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElement.GetRuntimeObject()
at System.Diagnostics.ListenerElementsCollection.GetRuntimeObject()
at System.Diagnostics.TraceSource.Initialize()
at System.Diagnostics.TraceSource.get_Listeners()
And it goes on for several more lines, but this establishes the context.
My question is, since, according to ObjectBrowser and Reflector, XmlWriterTraceListener is a member class of the same assembly that System.Diagnostics is, how can it NOT not be able to find it?
And secondly, since every single line in the exception stack comes from system code, how on earth do I begin to debug the root cause here?
Are you using .NET 4.0?
If not, you have to beware the service config utility. It will hard code the version of the listener to 4.0 and you'll need to manually change your web.config
I am developing an ASP.NET MVC 2 web site, targeted for .NET Framework 4.0, using Visual Studio 2010.
My web.config contains the following code:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="XhtmlModule" type="DomenicDenicola.Website.XhtmlModule" />
</modules>
<handlers>
<add name="DotLess" type="dotless.Core.LessCssHttpHandler,dotless.Core" path="*.less" verb="*" />
</handlers>
</system.webServer>
When I use Build > Publish to put the web site on my local IIS7 instance, it works great.
However, when I use Debug > Start Debugging, neither the HTTP handler nor module are executed on any requests.
Strangely enough, when I put the handler and module <add /> tags back into <system.web /> under <httpHandlers /> and <httpModules />, they work. This seems to imply that the development web server is running in classic mode.
How do I fix this?
You don't. WebDev.WebServer.exe does not and cannot support integrated pipeline.
So, if you have code that cannot be written to perform in both environments you will need to use a local IIS for development.
Basically, system.web is the place to configure webdev server and IIS5-6 handlers and modules. system.webServer is for IIS7 handlers and modules, as you know.
Reference:
Each request in WebDev.WebHost40 (and previous versions) is processed by HttpRuntime.ProcessRequest
(which does not support integrated pipeline mode). This is the method used in all three versions of WebHost.WebServer.dll (the core of WebDev.WebServer.exe)
And the word of some dude who is fairly familiar with the inner workings of Cassini/WebDev by virtue of managing this project. ;-)
I'm not sure if I'm too late in answering, but while it's known fact that the Cassini server doesn't support integrated pipeline mode, you can still test locally using the classic pipeline by adding it to the httpModules section of system.web in your web.config:
<system.web>
<compilation debug="true" targetFramework="4.0"/>
.
.
.
<!-- HTTP Modules using Classic Pipeline -->
<httpModules>
<add name="YourHttpModule" type="ACME.YourHttpModule"/>
</httpModules>
</system.web>
<system.webServer>
<!-- HTTP Modules using Integrated Pipeline -->
<modules runAllManagedModulesForAllRequests="true">
<add name="YourHttpModule" type="ACME.YourHttpModule"/>
</modules>
</system.webServer>
You'd probably want to remove the httpModules section from your production web.config.
Got this today while running in visual studio 2012. Found the reason was visual studio launched the old web server that comes with 2010 and as explained above it can't work there. Changed to IIS Express by right click on properties, choose "Web" tab and and selecting IIS Express option. Then launching debug mode will start in IIS Express and this aparently supports operations such as Request.Headers.Add or whatever caused your exception.