How can I set the default page for https requests? - asp.net

We have a website which has a Virtual Directory containing the secure portion of the website.
If users come to http://www.mydomain.com, they should get directed to default.aspx of the main site, but if they go to https://www.mydomain.com, they should go to default.aspx of the virtual directory.
The default page for the main site works fine, as does the secure page if I navigate to it using the full name, however I can't figure out how to set the default page for https traffic that doesn't specify a specific page.
http://www.mydomain.com - Works
https://www.mydomain.com - Page Not Found
https://www.mydomain.com/myvirtualdirectory - Page Not Found
https://www.mydomain.com/myvirtualdirectory/default.aspx - Works
What do I need to do to make links 2 and 3 load the default page show in 4?
My website is running on IIS 6.0 in Windows Server 2003

Overall, this is an anti-pattern as you state the entire behavior of the site changes based on the port. I am not stating definitively you are doing this, but consider the following:
If you are redirecting due to a user needing to see other things, you can make conditional controls that display only when in HTTPS. The same can be done for authenticated and authorized versus not.
If you are redirecting because an HTTP user needs to log in, the more consistent pattern is to have them click a log in button. And, you can force HTTPS at this point without breaking the pattern.
If you really need to redirect for some reason, there are a couple of ways of handling this:
In IIS
HTTP Handlers
URL Rewrite - requires the URL Rewrite bits for IIS 7
I imagine there are some other ways to solve this.

I finally figured out my issue. In my case, it turns out the problem was an old URL Rewrite rule I wasn't aware of that was transferring all https traffic that didn't have a file name specified to index.php, which of course didn't exist.
I found this out by viewing the IIS error logs, which was telling me the 404 was being caused by index.php

Related

IIS 10 web routing configuration

I am not sure how this done or what I need to do, I think all I need is a simple rewrite rule but I do not know.
I have a website that www.mysite.com loads the site, but when I browse to mysite.com it goes to a different page that basically says pageOk. I am not sure where that redirect is happening - as this was occurring with our old server (some one else managed that) - I installed IIS on a new server and so now the traffic at www.mysite.com is fine but I still have this issue of mysite.com showing a page that I do not have in my application.
What do I need to do to fix this or where might this issue be coming from ?
firest check the do any is URL rewrite rule and HTTP redirect is affecting this. check both server level and site level.
try to run failed request tracing in iis.
check browsers developer tool -> network tab which status code it is showing.
https://learn.microsoft.com/en-us/iis/troubleshoot/using-failed-request-tracing/troubleshooting-failed-requests-using-tracing-in-iis

Web.config redirect outside traffic for testing purposes

This is a bit of a tricky question.
I am developing a .net website, and it is hosted on our own servers.
I want to redirect outside traffic to a blank "coming soon" page, while our internal network can see the content.
How do I modify the web.config to do that?
I have already tried default document settings, but it doesn't seem to accept those, and instead displays the .NET website.
Please have a look at http://www.iis.net/learn/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module. It shows how to use IIS URL Rewrite Module (which in turns writes to web.config) to handle your scenario.

Umbraco configured with IIS 7 having hard time with the site URL?

I am having a problem with my Umbraco installation on IIS. The site is working, apart from my home button. When I push the home button, the URL should be
http:/myserver.mysite
instead the URL is
http:/myserver
When I type in the link it serves me the home page but when I click on the Home button it wont and the scenario described above occurs.
I am using IIS 7 and Umbraco 6.1.1.
If you are able to get to the homepage with both hostnames but then clicking on the Home link takes you to the second host, the link in the page must be referencing the hostname directly. If this is the case, check your HTML to ensure that the hostname isn't present in the link - basic I know but you have to check.
If it isn't, contrary to what Eric Herlitz says in his answer, I would ensure that you don't have anything set in the hostnames options. I only use the hostnames option when I need to control the hostnames of multiple root nodes. Umbraco will automatically assume that the first node in the tree is the default site. In other words, if you have two sites at the root of your Umbraco instance but only one hostname bound in IIS, Umbraco will serve the first of the branches as the default site, unless as Eric Herlitz states, you have specified the hostnames for specific nodes.
Instead, I would use the settings in IIS to ensure that requests are routed to the correct hostname. I know using Eric's approach is possibly easier, but it would undoubtedly mean that users will still be able to reach and browse the site using both hostnames. Ultimately from an SEO perspective this is a bad thing. Personally, I would ensure that any requests to anything but your preferred hostname are redirected to you hostname whilst retaining the path. This can be done via IIS using the UrlRewrite 2 module.
If you don't have access to this, you can use MVC routing (see here for an explanation) or the UrlRewriting module that comes shipped with Umbraco. With the latter, settings are specified in the ~/config/UrlRewriting.config file and documentation can be found here: http://www.urlrewriting.net/149/en/home.html
I would personally recommend familiarising yourself with all these techniques as they can be quite powerful.
Did you set your hostname in Umbraco?
Right click on the site root in your solution and click "Culture and hostnames"
Fill out your hostnames and save

URL Redirects in ASP.NET

Ok, wierd problem I cant figure out. Hopefully someone where can. I have inherited a site that was developed with a very over-architected Content Management System. I am having problems now with the redirection functionality built into it.
This is on a dedicated Windows 2003 server running ASP.NET 3.5 sp 1. The redirects are stored in the database, and I have confirmed that the correct redirect is in place in the database. Finally, the file extension .html has been mapped in IIS to the ASP.NET ISAPI. And there is an HttpHandler created to redirect the .html requests. The default documents on the server, in order, are:
default.aspx
index.aspx
default.asp
index.asp
default.html
index.html
for this example, we have two redirects both pointing to the same content page. /example and /example.html
when requesting /example.html it correctly finds the appropriate redirect in the database and does its magic. Bueno. When requesting /example it gives a 404 page. Its not even the asp.net yellowish 404 generic error page. Its the standard vanilla IIS 404 response so it appears that asp.net is not intercepting these requests.
Let me know if any other information is requested and I will try to provide what I can. Thanks in advance for all the great recommendation I am sure will come from the community.
You should be able to map a wildcard extension to go through the ASP.Net ISAPI DLL is the solution.
Installing Wildcard Application Mappings (IIS 6.0) may also be useful.
Without rewriting the CMS, you can put a physical file in a new directory "/example". This will trigger ASP.NET to intercept the request, and hopefully load your page.
If you want to really hack it up you can change the IIS 404 page to be a .NET page in your application that can handle the original request and redirect to the page you really want.
Yes this is correct because /example is not pointing to any file, it is pointing to directory in the web server. Check that Default.aspx/ default.html or any other atleast one of them exists in your app.
If you are using ASP.Net MVC for REST then check your actions are properly written.

Removing www from url in IIS 6

I have an SSL certificate setup for www.mydomain.com. I'm having a strange issue in IIS 6. When I navigate to www.mydomain.com everything works fine. Since the www. part is what my ssl certificate is registered under I get no issues. Hwoever, all of my links in my site take me to mydomain.com/mylink which causes a cetificate error because it's not prefixed with www. My website is ASP.Net and all my links are relative to the root (in other words I'm specifying ~/mylink and not hardcoding the mydomain.com part). Any idea why IIS or asp.net is removing www from all my links?
You could setup another website specifically for the non-www one and force it to redirect back to the www site.
Then setup logs in a different location and see if that lets you find the offending pages/links.
Otherwise you may have to use some link checking script to see if any links are coming out incorrectly. Normally, you should be using '~' in your links so that they get resolved by ASP.NET. This should give you an app relative root which shouldn't give you this error.
So you may have a few 'http...' links in there.
Failing that, I can't think of another reason!
HTH anyway.

Resources