IIS 10 URL Rewrite 2.1 can't rewrite to asmx - url

I've configured a rewrite rule in IIS to basically rewrite the request from http://mydomain to http://mydomain/subfolder/mywebservice.asmx and I can verify that the rewrite triggers and rewrites correctly.
However the problem is that once it's rewritten I get an IIS error "The file extension for the requested URL does not have a handler configured to process the request on the Web server."
When I navigate directly to http://mydomain/subfolder/mywebservice.asmx it works and the .asmx extension is handled correctly.
What am I missing?

I was missing the Application Request Routing extension. All that was required was to install ARR, then enable the proxy and the rewrite rules started resolving properly.
https://www.iis.net/downloads/microsoft/application-request-routing

Related

i want to transfer my ASP.NET MVC project to another server

I want to transfer my ASP.NET MVC project to another server(obvious with different IP address). I transfer the published code there and also map with the same link through IIS (and stop that site from previous server). And also change the connection string with updated database details.
I get this error:
Not Found
HTTP Error 404. The requested resource is not found.
Kindly help.
First of all, you need to figure out whether the request is sending the request to the right server. So please ensure the domain is pointing to the correct IP. Please ensure accessing the website via IP and domain name are getting same response.
If you are sure the request is reaching the right server, then you should see the 404 error in Server IIS log. Please enable failed request tracing and IIS detailed error to find the sub-status code and exception code.
If you see the 404 is returned from static file handler. Then please ensure IIS asp.net extension has been installed so that extensionless handler would help handle the MVC route URL.
If you have already installed asp.net extension. Please post more details and we may find the root cause.

issue with debug server proxy config

Using the angular 2 debug server, I proxy requests to the real server using proxy.config.js. It seems that the ng2-signalr library does not respect the proxy configuration, and will attempt requests to whatever was defined as url in the IConnectionOptions used.
for the following request:
GET
localhost:4200/signalr/negotiate?clientProtocol=2.1&user=client&connectionData=%5B%7B%22name%22%3A%22compilationhub%22%7D%5D&_=1557816148076
the following error is produced:
Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https
What would be the best course of action?
I got this working by adding the signalr route to proxy.config.js and setting the url property of my IConnectionOptions to location.origin. This setup bypasses the default route of /signalr so that a double forward slash route is not used.

MVC 5 app - facebook app redirects to the wrong URI - redirect_uri=http instead of redirect_uri=https

I have an app in facebook developer.
This app is configured with a "Valid OAuth redirect URIs"-value with a URL with https.
But when I click on the Login with facebook button on my page facebook redirects me to the http version of the URI. This seems like a facebook bug in their OAuth module?
I had exactly this issue when I deployed to an AWS Elastic Beanstalk environment with SSL terminated at the load-balancer. In this case, the request received from the load-balancer by the server looks like the client is connecting with HTTP, and the OWIN providers incorrectly infer that the URL Facebook/Twitter/Google needs to connect back into your site should use HTTP instead of HTTPS on the public side of the load-balancer.
I couldn't find a simple solution to this, there didn't seem to be any parameters to override the URI protocol which gets stored in the IOwinRequest.Scheme property. In the end, I grabbed the source code for the Katana project, and the source code for the ASP.NET Identity project, and I hacked it around a bit so that I had local projects in my solutions for:
Microsoft.AspNet.Identity.Core
Microsoft.AspNet.Identity.EntityFramework
Microsoft.AspNet.Identity.Owin
Microsoft.Owin.Security.Cookies
Microsoft.Owin.Security.Facebook
Microsoft.Owin.Security.Google
Microsoft.Owin.Security.OAuth
Microsoft.Owin.Security.Twitter
There was 50 or so other projects within Katana that I left out - I made all of these other dependencies Nuget package references to the official versions.
Then I found every reference to IOwinRequest.Scheme, and I replaced it with a snippet of code that also looked for the X-Forwarded-Proto header that is injected by the load-balancer when using SSL offloading.
Something like this:
var scheme = Request.Scheme;
if (string.Equals(Request.Headers["X-Forwarded-Proto"], "https", StringComparison.InvariantCultureIgnoreCase))
{
scheme = "https";
}
// Use the scheme in the construction of a URI...
If your load-balancer or proxy server doesn't provide the X-Forwarded-Proto header, then your options are pretty limited. You could re-encrypt the traffic and send it on to your server using the same protocol it came in on.

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

asp.net mvc 3 http 500 server error for .json file

I have a .json file sitting at the root of my site. The name of the file has dots in it (if that matters) and is sitting at a url like http://mysite.com/animated.config.json
When I do a $.getJSON() request for this file, it fails with an HTTP 500 error (internal server error occurred).
Is there a way (like with routes.IgnoreRoute() in global.asax.cs) to just tell the MVC routing to pass the request through and not try to route it? I suspect that's where the issue lies and I'd like to be able to tell MVC to just let any requests for .json files through and not bother routing them. I tried using the same syntax as I did for my favicon.ico file but it didn't work.
I tried this but it didn't work:
routes.Ignore("{resource}.json/{*pathInfo}");
Are you sure it's MVC's routing that's the problem, and not a MIME type issue with IIS? IIS will only serve certain mime-types by default and if the file has an unknown extension it won't serve it.

Resources