Remove the custom port number from https url using IIS - asp.net-mvc

I have a site which is configured in IIS7. Currently, the site named Site1, which uses the https protocol with a custom port number 5001. I can access this site by using the url given below:
https://demo.mydomain.com:5001/Site1
I need to eliminate the port number from the url, but it should access the same content which is used by the url "https://demo.mydomain.com:5001/Site1".
Expected result should be like this: "https://demo.mydomain.com/Site1"
Any help is much appreciated.

In IIS Manager, click on the Site (left pane) and the click Bindings (right pane). You'll see a binding for port 5001. Edit that binding to be port 443. (https://learn.microsoft.com/en-us/iis/configuration/system.applicationhost/sites/site/bindings/binding)
My guess though is you have some other site that is bound to port 443, if that is the case you either need to remove it from the other site, or if you need them to coexist, you need to dig into SNI which is a bit more advanced topic (SNI and SSL on IIS 8.5)

Related

Hosting two websites in a same IIS server using two ports

I have an IIS server which is hosted one website using default port number 80 and it is bind to mywebsite1.com:80. It is able to view using its domain mywebsite1.com without any issue. Now I hosted another website using port no 70 and need to bind mywebsite2.com to it. But since DNS record not supporting to the port numbers, I am able to view my newly hosted website using the URL mywebsite2.com:70. Is there any way to avoid putting port no there and access the website using its domain mywebsite2.com directly.
Windows Version : Windows Server 2016,
IIS Version : 10.0.14393.0
Thanks #Dusan Bajic and #Lex Li for the guidance. I was able to solve this issue by ticking the “Require Server Name Indication” in IIS site bindings.
Reference : https://www.sherweb.com/blog/cloud-server/host-different-ssls-on-one-ip-with-iis-8-sni/
Then i set up the HTTP/HTTPS redirect in IIS and now everything working fine,
(https://www.namecheap.com/support/knowledgebase/article.aspx/9953/38/iis-redirect-http-to-https)

ASP.NET MVC RequireHttps Page Not Found

I am trying to add the RequireHttps tag to a controller action but when I try to navigate to it I get a page not found error when I try:
https://localhost/MVCDemo3_4/Home/Index2
or
http://localhost/MVCDemo3_4/Home/Index2
The Http one tries to redirect to HTTPS but then the HTTPS can't find the page.
It depends more on how this is being hosted than the MVC attribute. If it's running off of a real IIS (or other full httpd) server on locahost, then you just need to make sure IIS is listening on both 80 and 443 (as #Jester mentioned, check the bindings). However, if you are using IIS Express via Visual Studio, then you really can only listen on one port and your debugging needs to be either all non-SSL or all SSL. This is controlled through the propeties on the Web project. Look at the Project URL field.

asp.net core RC2 iis hosting

I have hosted asp.net core app in IIS on window server 2012 R2 Standard. My site works fine when I use localhost based URL on the machine but when I try to access the URL using host name/machine name from network computer it does not work. What do I need to do to make it accessible from other computers?
There can be different reason for this:
Check your firewall to make sure your port 80 is open.
Check that the hostname point to the IP URL of your server.
What is the http code returned by the it does not work?
Tool:
Enter the Domain and IP, make sure they point to the same place.
http://www.hcidata.info/host2ip.htm
If firewall isn't the problem, and the site works via localhost on the server, make sure your IIS bindings are correct. Right click site, edit bindings, verify the domain / ip / etc match how you're trying to access it.

How do you force IIS Express to default to https URL?

I have enabled SSL in my MVC website for IIS Express by setting 'Enable SSL' in the project properties to true. So now I can access my site while debugging over http as well as https (IIS Express's default port 44300). However I'd like to force the default URL to be the SSL one. https://localhost:44300/. Whenever I run the app. from VS it always loads the http URL.
If I try and update the project URL (right click on the project -> click on properties -> navigate to the web tab -> set project URL to https://localhost:44300/) to https, the website fails to load. I just get a 'Page could not be loaded' error in the browser. However if I explicitly add a binding for https to port 44300 in my local IIS instance using IIS Management service it seems to work. I don't think I should have to touch local IIS in any way though.
Am I missing something here? Could someone help me figure this out?
The core of this seems to be finding the applicationhost.config file being passed to IIS, find the section like
<bindings>
<binding protocol="http" bindingInformation="*:62858:localhost" />
and change http to https
If you're using the Rider IDE, open the project properties (right click on solution explorer's icon for the project).
Make sure you add a port number for "SSL" and switch the Url from http://... to https://...
The port must be between 44300 and 44398, otherwise you'll get a connection reset error (see https://stackoverflow.com/a/24957146/423033 )
Sudeep,
If you are using the IIS on your machine (or on your server) you could create a rewrite rule that would intercept any http requests and will replace the http protocol with https.
Here is a link to get you started: http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module
As for IIS Express, it has its advantages of using it, but on the other side it is missing advanced functionality like URL Rewrite (check this link: http://weblogs.asp.net/scottgu/introducing-iis-express).
Best Regards,
Daniel D.
Figured it out. This tutorial is perfect and walks you through the whole process
http://www.lansweeper.com/kb/54/How-to-configure-SSL-in-IIS-Express.html

IIS Default Site

I have an IIS configuration such that [mywebapp] is an asp.net mvc web app that exists under "Default Web Site" of myserver.com.
How do I configure my IIS so that a request to www.myserver.com actually displays the home page of [mywebapp], without changing the url to www.myserver.com/mywebapp. Currently the url change is what happens as I am using HttpRedirect on Default Web Site, but this is not what I want.
Assuming that you have a DNS record set that maps your server IP address to the domain name, you will need to set up a new site, rather than a virtual directory underneath Default website. When you create the site, enter your domain name in the Host name field.
You can test this configuration locally first by setting the site up in IIS and then adding an entry in your hosts file (C:\Windows\System32\drivers\etc\hosts) that maps the domain name to your localhost IP address 127.0.0.1 - just remember to remove that once you're happy with the setup or you won't actually be hitting the live IP address.

Resources