IIS 7 and ASP MVC issue with period in query string - asp.net-mvc

I have an issue where I am sending over an email address to be validated against (make sure its not already used and is a valid email address). Now it worked fine on Cassini, but now I am using IIS7 it refuses to map the route.
The Url would look like:
http://localhost:23456/is/email/taken/test%40test.com
I have turned the route debugger on to make sure there is no problem with the route, and if I remove the ".com" bit at the end it works fine and the route matches (although its not a valid email address so is invalid). However if I leave the .com or whatever .extension is used, the route debugger doesnt even display so it makes me think IIS isnt even directing the traffic to ASP and is looking for a static file.
Has anyone else had this before? and if so how do you solve it?

OK, IIS may be treating that as a file with an extension that is blocked or mapped to a handler that is not MVC. It first checks to see if there is a physical file on disk so some of the handling of the URL isn't all MVC engine only. Do you have configurations that are protecting/refusing some extensions?

Related

URL Rewrite of Location is causing an Object Moved to here link to appear on site

I have an MVC site on IIS 8.0 I recently ran a security scan and failed saying that my internal IP address is being set on the HTTP response header. To mitigate this issue I installed URL rewrite and created an Outbound rule to replace the variable name RESPONSE_Location using wild cards and replacing it with an empty string. Doing this is causing an object moved link to appear when i access the site or click on any of the links. Any help is appreciated.
I think I got the issue fixed. I went to IIS Under ConfigurationEditor>System.WebServer>ServerRuntime and added the website name under alternateHostname... I'm not sure what fixed the vulnerability or the Object moved to here problem.. but both seem to have been resolved. I wish i knew what it was lo

URL Routes In IIS7 MVC 5 (Single Paged Application)

After publishing a MVC5 web application of mine to my IIS server (Individual User Accounts), it would seem that the URL is accessed incorrectly.
During debug, it would be e.g http://localhost:1234/api/Account/UserInfo?=XXXXX
The debug works just fine. The only issue kicks in after I've published it via my IIS7 server.
After publishing and using Google Chrome's console, it would appear that the page is requesting for a resource at mydomainname.com/api/Account/UserInfo?=XXXX instead of mydomainname.com/WEBAPPLICATIONNAME/api/Account/UserInfo?=XXXX.
My best guess is to modify the URLs in /Scripts/app/app.datamodel.js but it would just cause more parsing problems.
I've searched around and can't seem to find any related problems. I hope someone here will be able to lend a hand.
Look like you are using relative path like "/api/Account/UserInfo". Instead i'll recommend you to use #Url.Content("/api/Account/UserInfo"). This will solve your problem
Explanation
In local system when we run application in WebDev server it never have sub folder (like WEBAPPLICATIONNAME) therefore you relative path work correctly. but when you host your application in IIS under Default website in another new website /Virtual folder (like 'WEBAPPLICATIONNAME') then "/api/Account/UserInfo" fall back to Default Website because for '/' in starting. #Url.Content or #Url.Action make sure to add virtual directory name, hence changing your path to "/WEBAPPLICATIONNAME/api/Account/UserInfo" in IIS.

ASP.NET MVC server path is different from application path

I have an unusual circumstance where our web server inserts a folder into the url path before loading the page. Let me give you an example:
The app is called equipment and if I were to run it on a normal server setup, it would look like:
www.site.com\equipment\home\index
BUT when I run it on our server, it inserts "idn" in the url:
www.site.com\idn\equipment\home\index
The messes up my relative references. The MVC functions want to redirect to use "\equipment\" instead of "\idn\equipment\". This happens with Scripts.Render(), Return View(), etc.
Also, I can't hardcode the "idn" into my urls b/c then it is no longer relative and it won't work on my dev box or test servers b/c they don't have a "idn" subfolder in localhost.
I also tried functions such as Request.ApplicationPath and what not but none of them return the "idn" in the result.
Is there way to MVC to know that this "idn" was inserted into the url and account for it?
Thanks!
Create your application on the test/production server in the idn folder, then it all works.

MVC.NET 404 outside of Domain

I am trying to get a demo site for a client setup. This is the 1st application my company is doing in MVC.NET, so I get to experience all the new things to find out (and all the headaches it'll cause).
Anyway, the site works fine locally (localhost) and on the server inside our domain. External users not on the domain however, only get 404 errors. I've tried several different settings/ config options I've found on this site, but nothing is working. I don't know if it's a web.config issue or an IIS issue, or even simply a permissions issue (though it has all the same permissions as the other sites we run with Web Forms).
IIS: v7 in intergrated mode.
Windows Server Web
Well, because you received a 404, the server is being reached okay which is a good sign. (Dealing with firewall issues at a company is always a lot of fun.)
A common problem for something like this is the use of virtual directories to host the website. For example, if the address to your site is http://example.com/MySite/, in MVC that would translate to: /MySite/View/Index.aspx. HOWEVER...if you are using virtual folders, /MySite/ may instead point to another spot on the server (e.g. C:\WebSites\MySite). If you are indeed using virtual paths, make sure you have your files stored at the correct path.
There is a troubleshooting tutorial here: http://support.microsoft.com/kb/248033
thanks for the answers everyone. Turns out it was something with our DNS routing setup with the sub-domains. It was getting rerouted to a place that didn't exist. Our IT guy finally got around to fixing it (ugh!)

Possible to have ampersands ("&") in URL BEFORE the query string?

My client is determined to have a page at /nfm&t so I made a directory named nfm&t with an index.html (to test) and that URL is still throwing a 404. So apparently it's not that easy.
Any ideas? Or is there a way to just redirect nfm&t to nfmt, so that the URL at least resolves?
This is a Windows server, by the way, which throws a wrench into how I'm used to doing redirects.
Turning on AllowRestrictedChars and enabling VersionCompatibility should do it.
Why would a Windows Server throw a wrench into how you do redirects? If you are using IIS 7, you can use URL Rewrite Module. It is built into IIS. If you are using IIS 6, there is ISAPI Rewrite, which is an external module. Both use the same syntax as mod_rewrite for Apache.
Do you have a /nfm directory? If you don't, try making one. Either way, put in a Default.aspx file and have it spit back at you the exact path it's trying to access. Chances are, when you have this here, it will go to example.com/nfm/Default.aspx and let you run something from there.
If you do get to that directory, then try redirection to example.com/nfm%26t and see if it works. If this still doesn't help it, then you're SOL
I tried this on my Snow Leopard ( OSX 10.6.2 ) workstation with Apache and it works. That is from Firefox 3.6. Looks like a Windows thing you are struggling with. Honestly I didn't think that would work without encoding but you never know until you try.
alt text http://www.vertigrated.com/images/so_screenshot.png
Or is there a way to just redirect
nfm&t to nfmt, so that the URL at
least resolves?
Sure. Make a general url handler and/or an error handler. When it encounters a url, if that url is equal to /nfm&t, then under the hood rewrite the context to whatever page you actually really want to return. Is this a good idea? Probably not. But it will work. Keith's answer suggests two ways to grab the url and do stuff, though you could also do this via a global asax file (being careful to execute an aspx page when you hit an error so it actually gets hit) if you're using .Net.

Resources