Web.config: Redirect from http to https - web-config

I'm new to ASP.NET, i have developed a website and hosted it on GoDaddy.
Is it possible to have a folder under the website requires an https to access it or any file under it? in other words, when any file is loaded from that folder the URL address will turn into HTTPS://
Thanks

Decorate the controller which provides access to those URLs with [RequireHttps].

Take a look at http://www.dantor.com/support/misc/web-config-response-redirect.aspx it has some great examples. I guess you can use one of those to redirect to the https URL.

Related

Redirects on Google Cloud Run

I've got a clients site that uses Google Cloud Run and I need to implement some redirects as they have both www. and a non www. version of the site simultaneously.
https://www.example.com
https://example.com
I would like to setup a redirect so that it goes from www. to the non www. version. I know I can't do this at DNS level for this type of redirect so am looking at doing it at a server level. I've checked for documentation on this on Google Cloud run and can't seem to see anything relevant. I've never worked with a client site that uses cloud run before, but have a good idea of how I'd go about doing this on a website that uses Apache or Nginx.
Does anyone know if there is a specific file where I should be implementing redirects within the Cloud Run setup?
Thanks,
Adam
You should do this in the code. For example if you were using Python with Flask, you can implement it in your #app.before_request

http to https redirect via application load balancer not working in iphone safari

We are doing a redirect from http to https on our AWS application load balancer that works great in most browsers, but doesn't work in safari in an iphone. The redirect is implemented as outlined here https://www.fischco.org/technica/2018/aws-alb-redirects/
In safari, our site works perfectly in an iphone when you load it via https, but when you don't include a protocol or use http, it says "Safari could not open the page because the server stopped responding."
Any ideas on how to fix this without doing client-side redirection?
This seems to be an Apache bug (https://bz.apache.org/bugzilla/show_bug.cgi?id=59311), for which a solution can be found here: https://serverfault.com/questions/937253/https-doesnt-work-with-safari (check out Steffen Ullrich's answer and the comments)
TL;DR;
Add this to your host config
Header unset Upgrade
OR alternatively, add this to your .htaccess file (see Disable Apache http2 announce via htaccess)
Header edit Upgrade (.*)h2,h2c(.*) "$1$2"

Two zend applications: one in a subdomain, one on root

I'm using Zend for my corporate website. This website contains two seperate applications, namely the website itself (which is a CMS) and the customer panel. The administration panel will be launched on a subdomain, namely customer.domain.com. The website runs on a shared hosting package.
What would be the smartest configuration for this situation?
Thanks,
Martijn
Create the admin panel as a module then use the Hostname router to direct the sub-domain requests to it.
I've choosen the following configuration. On domain-level I've created the application folder. This folder contains two folders, namely 'cms' and 'billings'. I've also created a ServerAlias so that the subdomain points to index.php. In index.php I use PHP's $_SERVER HTTP HOST to determine which application needs to be loaded.

Facebook connect

I have an asp.net site and I use log in to facebook calling
http://www.facebook.com/login.php?api_key=API_KEY&connect_display=popup&v=1.0&next=http://localhost/site/login.aspx&cancel_url=http://www.facebook.com/connect/login_failure.html&fbconnect=true&return_session=true&skipcookie=true
Logs in very well, returns to my site, I see session parameter in url, but I can't catch any postback or something.
Could you help me, please?
Thank you
A couple of things to check:
Make sure that http://localhost/site (or whatever the url for the root of your app is) is set in your application's connect settings
If you're using the Visual Studio development studio development web server (Cassini), your app's url will include a port (for example, http://localhost:34256/site). This url (including the port) will need to be specified in your connect url in your application's settings on Facebook.

ASP.Net MVC + Wordpress

I have ASP.Net MVC project. Plus wordpress blog under a subfolder "/Blog".
Now, when I access the URL www.domainname.com/Blog, I get the following error:
"The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map."
I guess the problem is because the Blog url is accessing a .php files (Wordpress) which MVC Routing handler does not understand.
Can you please help? What can be done?
Does your hosting support PHP? It does not look like a routing exception, more like a server config error.
I found the solution.
In my server admin (Plesk), I had an option to run php as CGI app, FastCGI or ISAPI Extension.
Earlier it was CGI app. So it did not work.
I set it to ISAPI Extension and it worked.
Thanks.