ASP.NET + MVC 3 + IIS7.0 + HTTPS requests
In short how do I setup HTTPS requests in IIS7.0 (NB: I am not using IIS express). Ideally only for the events in my AccountController is all I need but I can come back to that. I have read up on a few posts and I getting to understand them however I guess I just need direction as I am not sure what is going on. What I have done is as follows:
Web.Config:
<authentication mode="Forms">
<forms name="MyMVCAUTH" loginUrl="~/Account/LogOn" timeout="20" protection="All" requireSSL="true"/>
</authentication>
In IIS7.0:
Created a new website by adding the path to my code and used the DefaultAppPool
I edited the permissions and added IIS_IUSRS user with "read & execute"
Changed the DefaultAppPool to use the latest .NET framework
Created a new Self Signed Certificate and added a https binding
My "Default Web Site" which was pointing to port 80 I stopped and applied the default ports of 80 and 443 to my new site.
Ran my application thru VS "MS Visual Web Developer 2010 Express" with debug=true and removed an offending line of targetFramework="4.0" which it did not like. However, clicking on my [Log On] link my CSS styles have been removed!?!? Do I need to specify the port number via VS some how? Via VWD it chooses a random port number and when you click on the hyperlink it removes the port number?
Since you have created a self signed certificate, IE doesn't recognize it coming from a valid certification authority and it warns you about when you navigate to the website. You could ignore the warning by continuing to the web page. The same ting happens with your CSS and javascrpt links. So here's what you could do: Copy-Paste the link to your CSS and JS files into the browser address bar (with HTTPS) and ignore the warning. Then refresh the actual page (Ctrl+F5) and the styles should reappear.
Related
I'm using Visual Studio 2019 (as Administrator) and IIS Express with the extra Widows 10 features needed to publish web sites on the internet. I created a new Blazor app with the following choices:
Server Side
.NET 5.0 (because .net3.1 does not have ProtectedBrowserStorage)
Authentication - None
Configure for HTTPS (because my domain name uses Cloudflare servers)
Enable Docker - No
Environmental variables
Project properties - None
Windows AdvancedSystemSettings - Development
I did not add any more components nor did I modify the default code.
I built and ran it in release mode.
The web site displayed the home page on a Chrome browser.
I could navigate to the Counter page.
When I clicked the "Click Me" button the current count incremented as it should.
Then I published it to the default file ("~bin\release\net5.0\publish).
I copied this file (with admin privileges) into inetpub and renamed it "B02".
In IIS I created a new web site called B02 specifying the physical path as C:\inetpub\B02.
New App Pool B02 was created and I accepted it.
I did not add a specific user so Test Connection failed but I think this is OK.
I added two bindings
https port 443 IP Address *
https port 443 IP Address 19.168.0.34 (the reserved address of the computer on the router to which port 443 is forwarded. i.e. I'm using port forwarding on a NetGear router)
I could then click, in IIS, "Browse*:443(https) and the web site was OK. I could navigate to any page and all links worked including the "Click Me" button which incremented the counter.
The problem is that when I enter into the Chrome browser the address
"https://www.bkdaniels.com" the web site appears, I can navigate to any of the three pages, the About button works, the "Brief Survey" button works BUT THE "CLICK ME" BUTTON DOES NOT INCREMENT THE COUNT. (It does change the style of the border of the button).
I have presented this simple problem in the hopes that it will enable me to make user interactions work on a custom web app I have written. Presently they all work in IIS browse but not over the internet.
My domain name "bkdaniels.com" is registered with GoDaddy where I have specified to use name servers at Cloudflare because Cloudflare provides and SSL Certificate that prevents clients seeing a warning about the site being not secure.
7/29/22 A solution has been found.
A couple of trivial changes that cleaned up warnings in the Browser console were as follows:
Installed 6.0 SDK
Added to Program.cs - app.UseWebSockets()
These alone did not solve the problem. the Counter click me button still failed to increment the count.
The action that solved the problem was to go to GoDaddy and change the nameservers from Cloudflare servers to GoDaddy default name servers.
I then had to by pass the security warning since I no longer had the SSL certificate that Cloudflare provided. So I clicked "Run Anyway".
The "click me" button incremented the counter.
I will now work with Cloudflare support to find a way to make it work through their nameservers.
8/15/2022 I have now found that a temporary workaround is to set the Cloudflare Dashboard Cache to Developer Mode. This solves the problem with the counter button and also enables my main web site to work. I am still looking for a proper solution.
8/29/2022 SOLUTION
This solution enabled the click on the default Blazor Server app to work and it also enabled my serious web site to work perfectly.
Cloudflare/ logon/ domain name/ dashboard/ speed/ optimization/ auto minify/ HTML / OFF
.
I have to test a Web Service with visual studio 2015, using IIS.
I have a project "MyWebService", this project contains a page "myPage.ashx". When I start the project my chrome explorer starts on page localhost - /. There I can see all file in the project.
But when I click on myPage.ashx I got an error 404 :
HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
I changed the property "browse to URL" to ~/myPage.ashx but there is no difference. I'm very new to web services and I need help to know where I have to looking for.
.ashx file extension might not be defined in your IIS.
See official documentation on Microsoft site How to: Configure an HTTP Handler Extension in IIS.
I would like to try testing virtual hosting of an ASP.Net MVC website on my local machine. In Visual Studio in the Web tab of the properties file for the MVC project, I selected Use Local IIS Web Server. By "virtual hosting", what I really mean is that I'm trying to make sure that pages load correctly for urls of the form http://sub-domain-i.my-domain.com/MyMvcProject/Controller/Action, where I'm hoping to test multiple subdomains in place of sub-domain-i. In production, everything will be running under a single IP address on one server. I also hope to test https for urls of this form using a wildcard ssl certificate, but currently I'm having trouble configuring Visual Studio to just test regular http. Prior to worrying about sub-domains, the Project Url field in the Web tab of the properties folder for my MVC project said "http://localhost/MyMvcProject", and everything worked fine. However, after changing this to "http://sub-domain-1.my-domain.com/MyMvcProject" and then adding the following line into my C:\Windows\System32\drivers\etc\hosts file,
127.0.0.1 sub-domain-1.my-domain.com
Visual Studio produces the error "Unable to create the virtual directory. http://sub-domain-1.my-domain.com/MyMvcProject". Does anyone know what I might be doing wrong?
Many thanks in advance!
Edit: I've just discovered that if I select Use Custom Web Server instead of Use Local IIS Web server, it works and I don't get the popup error from Visual Studio. I'm still not sure why this solution works, though, or what I was doing wrong by selecting Use Custom Web Server...
A little late, but I hope it helps somebody.
You need to create the binding in the IIS website prior to add it to the project url of the project. That binding must be like
http | sub-domain-1.my-domain.com | 80 | * or 127.0.0.1
How to create a binding
I have an MVC 3 application which I have been developing, which uses Forms authentication. In my web.config file the only authentication code I have is:
<authentication mode="Forms">
<forms loginUrl="~/Account/LogOn" timeout="2880" />
</authentication>
I then use the [Authorize] tag on each individual controller I need to restrict access to.
I run the system on my development machine (Windows 7), an online demo server (Windows 2003 with IIS6.5) and a local production server (Windows 2008 Web Edition R2 with IIS7.5).
When I access the system on the Win2008 server, I am redirected to the login page as expected, however none of the CSS stylesheets load, and all images are missing (all located in the Content folder). This only occurs on the Win2008 server, on my local dev machine and on the Win2003 machine, the CSS and images load just fine.
There are no restrictions on the Content folder, in fact it even contains its own web.config explicitly allowing access to non-authenticated users. I have also tried adding a line to the main web.config allowing full access to Content.
If I place a .htm file in the Content folder, I can access this in the browser. If I try to access an image or a .css file however, I am immediately redirected to the login page!
I am stumped as to what may be causing this.
As mentioned by Wim, the duplicate thread has the answer (although in the comments to the accepted answer in my case).
The problem is caused by the Authentication settings in IIS Manager.
Select your site, then select Authentication. Ensure both Anonymous Authentication and Forms Authentication are both enabled.
In my case, I also had to change the anonymous user - to do so, right click Anonymous Authentication and select Edit. Change it to Application pool identity.
After this, the images and styles load perfectly!
I am have a web application on local IIS (mylocalsite.com)
What settings I need, so that I can handle all subdomains of my local site, like
user1.mylocalsite.com
user2.mylocalsite.com
anything.mylocalsite.com
All urls will point to same index page from where I can seperate subdomain and load page accordingly.
Since your description is not that clear, my initial thought would that you can setup different Bindings in IIS to cater for all the subdomains.
In IIS 7, right click your website -> Edit Bindings -> Add..
But my guess would be that you may need to do this from code, since users are added to your system (assuming user/sub-domain model). For this I refer you to
Create Binding in in IIS (iis.net)
Cool new IIS7 Features and APIs - ScottGu
Microsoft.Web.Administration