Unable to disable SSL for website - asp.net

I created a website and deployed it to Windows Azure. Somewhere during development I enabled SSL from the project properties and everything (https address) was working fine in localhost and on the Azure website where I deployed my site.
Now my Azure trial is expiring and I am moving my website to another free asp.net hosting that does not support SSL without paying for it.
So I'm thinking it is going to be easy, just set SSL Enabled back to False as it was when I first started development and everything is fine, but that is not the case.
My website refuses to work after I disabled SSL.
Picture of my Visual Studio setting with IIS Express opened and showing that there is a server on the right address: http://db.tt/EKTcxPsd
When I launch the site from Visual Studio it starts loading the page localhost:44300.
After a few seconds I am redirected to https://localhost that displays a "webpage is not available" error. Picture: http://db.tt/VntZTpKD
I have tried deleting the IISExpress folder and relaunching visual studio. The recreated applicationhost.config file has the correct information (as far as I know)
<site name="PrototypeNew-bootstrap3" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="E:\path-shortened\Visual Studio 2013\Projects\PrototypeNew\PrototypeNew-branch" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:44300:localhost" />
</bindings>
</site>
I have the same problem after publishing the website to a hosting environment.
Going to http://mywebsite.com redirects me to https://mywebsite.com and shows the same error as the localhost page.
If I re-enable SSL then the https address on my localhost starts working fine.
Does anyone know what is going on here? Is there another SSL switch somewhere that I forgot to turn off? Why is it always redirecting me to https
EDIT. Tried creating a new asp.net mvc 4 project. Launched it and it was working fine. Copied the web.config to my project and it was still redirecting to https:localhost

Okay I finally found the solution. FilterConfig.cs looked like the following:
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new HandleErrorAttribute());
filters.Add(new System.Web.Mvc.AuthorizeAttribute());
filters.Add(new RequireHttpsAttribute()); // problem
}
It must have automatically added the RequireHttpsAttribute when I enabled SSL and then didn't remove it. Removing it manually fixed the problem.

Related

ERR_SSL_PROTOCOL_ERROR for localhost from Visual Studio debug

I am running a simple ASP.net web application. Chrome is showing the below error after running this.
localhost sent an invalid response.
Try running Windows Network Diagnostics.
ERR_SSL_PROTOCOL_ERROR
but my application is on http, not https.
but the URL is loading with https://localhost:54056/
config is also pointing to http only.
<site name="tan-square" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Users\Myfolder\OneDrive\Downloads\tan-square" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:54056:localhost" />
</bindings>
</site>
I don't understand where the problem is. Why is it loading with https?
First, check your site web binding detail by the following detail:
Open visual studio, select your project.
right-click on the project and select properties.
under the Web tab and check your project url.
make sure there no such setting in your web.conifg file like below:
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security"
value="max-age=16070400; includeSubDomains" />
</customHeaders>
</httpProtocol>
</system.webServer>
When the browser sees this, it will remember, for the given number of seconds, that the current domain should only be contacted over HTTPS. In the future, if the user types http:// or omits the scheme, HTTPS is the default.
Clear your browser cache.
Another thing you could try to find the cause is open chrome and type chrome://net-internals/#hsts in the address bar and search for localhost:
The query shows “localhost” as being in the list of domains in the HSTS set.
The solution is deleting the domain from the cache. type “localhost” into the Delete domain text field, and hit Delete. After doing that when you query for “localhost” again you will receive a “Not found”.
Just create new Virtual Directory:
1-right-click on the project and select properties.
2-under the Web tab change your project url by changing the localhost to http://localhost:48333/ .
3- click Create Virtual Directory.
4- make sure you don't have this in web.config
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="Strict-Transport-Security" value="max-age=16070400; includeSubDomains"/>
</customHeaders>
</httpProtocol>
</system.webServer>
If you are running .net core, just run Visual Studio as admin, or go to bin\Debug\netcoreapp3.1 directory, and issue. Wierdly, .net core. .net core surprisingly dont give any error.
%USERPROFILE%\\.dotnet\\tools\\dotnet-lambda-test-tool-3.1.exe --port 5059
change port number to whatever.
Go to launch settings
change the launch URL to https instead of http,
it will ask you to add self generated ssl ,
click Yes and it Run the project.
Hope this will help you
In my case "clearing SSL State" has solved my issue.
Open the Start menu.
Search for and open Internet Options.
In the dialog box that appears, select the Content tab.
Click Clear SSL State.
Change default browser to Chrome and the issue is solved.

ASP.NET MVC request handled by StaticFile handler because of AppPool configs?

Sometimes, on my Windows 7 laptop, my ASP.NET MVC applications would fail with an error like:
HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.
Detailed Error Information
Module DirectoryListingModule
Notification ExecuteRequestHandler
Handler StaticFile Error
At the same time other MVC applications worked fine. So, I knew I had everything installed correctly. I tried the ideas in ASP.NET MVC on IIS 7.5 but none worked for me.
My guess was that MVC or ASP.NET was not configured correctly, so IIS did not interpret the URL correctly and map it as an MVC application that should use routing. The correct HttpModule was not being found, so IIS was treating the request as for a static page and redirecting to the folder, but since directory browse was not enabled, I was getting the error.
I finally stumbled around my file system and noticed two directories with config files:
C:\inetpub\temp\appPools\DefaultAppPool\DefaultAppPool.config
C:\inetpub\temp\appPools\ASP.NET V4.0 Integrated\ASP.NET V4.0 Integrated.config
These config files contained a bunch of incorrect application definitions. Some of these were for applications that did not show up in IIS Manager. Here is an example of two (one is incorrect, one is correct):
<system.applicationHost>
<sites>
<site name="Default Web Site" id="1" serverAutoStart="true">
<application path="/appsuite/billing/customer/log-in" applicationPool="ASP.NET V4.0 Integrated">
virtualDirectory path="/" physicalPath="C:\dev\appsuite\trunk\appsuite.Services\Billing\src\Billing" />
</application>
<application path="/appsuite/billing" applicationPool="ASP.NET V4.0 Integrated">
<virtualDirectory path="/" physicalPath="C:\dev\appsuite\trunk\appsuite.Services\Billing\src\Billing" />
</application>
My problem was when I attempted to request a URL that matched one of these apps with a bad path, like http://localhost/appsuite/billing/customer/log-in, I would get the 403 error.
I deleted everything in C:\inetpub\temp (I figured, hey it's a temp folder) and after hitting my url, the config files came back. I then manually deleted from the config file the applciation that matched my url and the app started working.
Where do the settings for these config files come from, where is the data coming from after I deleted them?
How can I clean up the old junk that is in them that isn't used any more?
I suspect I created this mess in Visual Studio. Sometimes when setting the Web properties of a project, I would accidentally set the Project URL to my launch URL, when I really meant to set the Start URL to this value. My guess is this set up a new web app with the url that matched my start page.

IIS Express http/https bindings not working correctly

I have a solution with 6 projects in it. And for 2 of them I enabled SSL in project properties.
The problem is, that when I start debugging, all my projects starts with https, even if they're not configured to use SSL.
E.g. before enabling SSL my project was accessible via http://localhost:63684/. Now, with https enabled I can access my project under https://localhost:43000/, but when I try to access this url: http://localhost:63684/, it automatically changes to https://localhost:63684/ and I get the following error in the browser:
SSL connection error
ERR_SSL_PROTOCOL_ERROR
Unable to make a secure connection to the server. This may be a problem with the server, or it may be requiring a client authentication certificate that you don't have.
The same goes for the projects, which doesn't have SSL enabled and I can't access them.
...\Documents\IISExpress\config\applicationhost.config file has proper bindings:
<bindings>
<binding protocol="http" bindingInformation="*:63684:localhost" />
<binding protocol="https" bindingInformation="*:44300:localhost" />
</bindings>
And other 4 projects, which doesn't have SSL enabled, but are still automatically switched to https:
<bindings>
<binding protocol="http" bindingInformation="*:11483:localhost" />
</bindings>
I already tried to delete IISExpress folder, because I thought config is broken somehow, but it didn't help.
Any ideas what causes automatically switching to https and how to fix it?
BTW, I was following this article when implementing https in my 2 projects and my goal is to be able to use http when debugging locally and https when project is published to the web.
Turns out, that it was a Chrome problem, because I noticed, that on other browsers everything is working well. This SO answer helped me to fix this issue.

VS 2013 / IIS Express - serve site from localhost:port/myapp instead of localhost:port

In prod my site (mvc5) is hosted on https://company.no/myApp/ where myApp is an Application on IIS.
In dev my site is hosted on IIS Express on http://localhost:54307/
As this causes some truble with server relative paths I would like to also do my debugging on http://localhost:54307/myApp.
This is what I've tried:
Setting project url in property pages to http://localhost:54307/myApp and clicking Create Virtual directory
Tried the override application root with or without the myApp url.
Tried modify the applicationhost.config. Currently my setting looks like this:
<site name="MyApp.Web-Site" id="38">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\OP\MyApp\Main\src\MyApp.Web" />
</application>
<application path="/MyApp" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="C:\Projects\OP\MyApp\Main\src\MyApp.Web" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:54307:localhost" />
<binding protocol="https" bindingInformation="*:44307:localhost" />
</bindings>
</site>
When I try to open page from the myApp folder I get the follownig error:
Module IIS Web Core
Notification BeginRequest
Handler Not yet determined
Error Code 0x800700b7
Config Error Cannot add duplicate collection entry of type 'add' with unique key attribute 'name' set to 'WSFederationAuthenticationModule'
Config File \\?\C:\Projects\OP\MyApp\Main\src\MyApp.Web\web.config
Requested URL http://localhost:54307/MyApp
Physical Path C:\Projects\OP\MyApp\Main\src\MyApp.Web
That indicates web.config loaded twice. Any idea what I'm doing wrong?
Thanks for any help
Larsi
I hear you with IIS Express causing problems with server relative paths. You can set this up with a couple steps that don't include manually editing your applicationhost.config. I try to avoid editing the applicationhost.config manually, it seems to cause more problems than it solves. I would remove the website from your local IIS to clear out any of that stuff and then do the steps below:
right-click on your web project and select properties.
Click on the "Web" menu
change the dropdown to Local IIS and enter the URL you would like the app to resolve to then click create virtual directory, save the file and build.
You can still debug without the port number, the debugger will just attach to this new website in your local IIS instance as long as you have a debugger option checked on the web tab.
open your local IIS and make any other configurations that are required for your app to run (Authentication, Application Pools, etc.).
open your browser and navigate to http://localhost/YourAppName
since this is a website as far as your local iis is concerned, you can hit it anytime in a browser without needed Visual Studio running.

Invalid application path

IIS7 Windows 7 64bit
No matter what I do I can't seem to add an application to a web site.
When I 'Test settings' I get "Invalid application path".
Any one have a guess as to what I could be doing wrong?
When I got this error it appeared to be due to a security setting. When I changed the "Connect As" property to an administrator then I no longer got the message.
Obviously this isn't a good solution for a production environment - one should probably grant the least privileges necessary for the user IIS is going to be using by default. I'll update this answer if I learn more.
The error message might be a bug. I ignored it and everything worked for me.
See Here: http://forums.iis.net/t/1177952.aspx
and here http://forums.iis.net/p/1182820/2000936.aspx
I eventually tracked this down to the Anonymous Authentication Credentials. I don't know what had changed, because this application used to work, but anyway, this is what I did:
Click on the Application -> Authentication. Make sure Anonymous Authentication is enabled (it was, in my case), but also click on Edit... and change the anonymous user identity to "Application pool identity" not "Specific user". Making this change worked for me.
Regards.
Go to your HTTP bindings in IIS (select your website, then on the right click on Bindings...).
Delete your SSL and your HTTP binding. Re-Add them.
This usually fixes this for me.
Try : Internet Information Services (IIS) Manager -> Default Web Site -> Click Error Pages properties and select Detail errors
Problem was installing iis manager after .net framework aspnet_regiis had run. Run run aspnet_regiis from x64 .net framework directory
aspnet_regiis -iru // From x64 .net framework directory
IIS Manager can't configure .NET Compilation on .NET 4 Applications
I was also getting this error, I found that it was because I had deleted the Default Application Pool "DefaultAppPool". Re-creating it fixed the problem. Drove me crazy for a few days.
This error will appear if either the web application is mapped to a non-existent app-pool; or if that application pool is stopped.
I also had this error.
My IIS Website has a Default Website with three (3) application directories below it.
I had each of my 3 application directories configured correctly to use .NET Framework v2.0 in the Application Pools.
However, the Default Website never was configured. I didn't think it was necessary since all of my apps were contained within it.
My IIS Server's default configuration is .NET Framework v4.0, so I changed that to .NET v2.0:
After I did that, I no longer received the same error message.
Now, I see this:
I hope this information helps others.
I was also getting this error. The problem for me turned out to be that I had two separate websites on the machine, and I had not designated which address went to which website. To resolve this, go to IIS Manager -> Select Web Site -> Bindings -> Add... -> Enter the host name that you want to resolve for this website. Repeat for any other websites on the machine.
HTH. Rick
I had a similar issue today. It was caused by skype! A recent update to skype had re-enabled port 80 and 443 as alternatives to incoming connections.
H/T : http://www.codeproject.com/Questions/549157/unableplustoplusstartplusdebuggingplusonplustheplu
To disable, go to skype > options > Advanced > Connections and uncheck "Use port 80 and 443 as alternatives to incoming connections"
I still haven’t find a solution, but find a workaround.
You can manually change IIS configuration, in system32\intsrv\config\applicationHost.config. Just manually create (copy-paste) section in <sites> and <location>.
This worked for me. (btw its not recommended.)
For my test app , I created a new application pool and changed its Identity to "NetworkService" .
More about App Pool Identities here
http://www.iis.net/learn/manage/configuring-security/application-pool-identities
and
http://www.iis.net/learn/get-started/planning-for-security/understanding-built-in-user-and-group-accounts-in-iis
You have to make sure that "NetworkService" has rights on your application's physical path.
even it was getting the above error. i found out that IIS was not registered on the server.
registering the iis fixed the issue.
Thanks,
In my case I had virtual dir. When I accessed main WCF Service in main dir it was working fine but accessing WCF service in virtual dir was throwing an error.
I had following code in web.config for both main and virtual dir.
<security>
<requestFiltering>
<denyQueryStringSequences>
<add sequence=".." />
</denyQueryStringSequences>
</requestFiltering>
</security>
by removing from web.config in virtual dir it fixed it.
I was able to correct the flaw by changing the file below:
C:\Windows\System32\inetsrv\config\applicationHost.config
In:
<application path="/" applicationPool="ASP.NET v4.0">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\Bonobo.Git.Server" />
</application>
<application path="/Bonobo.Git.Server" applicationPool="ASP.NET v4.0">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\Bonobo.Git.Server" />
</application>
For:
<application path="/">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\" />
</application>
<application path="/Bonobo.Git.Server" applicationPool="ASP.NET v4.0">
<virtualDirectory path="/" physicalPath="C:\inetpub\wwwroot\Bonobo.Git.Server" />
</application>

Resources