Special character in URL on IIS, IIS hanging - asp.net

I have tumbled with a problem with IIS on the Windows Server 2008 R2 for some time now. I have a website that needs to be moved to this server.
What happend when we move the solution is that every URL that have special character as æ, ø, å, á or spaces (%20) etc. will not work, hanging and lastly times out. The problem occours both on images and files (ashx, gif, jpg). Everything looks like it's being URL encoded.
We have no issue at all on the old server on this matter.
Here is some example of the issue:
http://biva-search.workingpropeople.com/~/media/Flash%20-%20og%20alternativer%20740x188/TLFlash/Timberman.ashx?w=740&h=231
http://biva-search.workingpropeople.com/~/media/170x120/Boerne_t%C3%A6pper.ashx?mw=170
I'm sure it is some crazy settings I missed out and I hope someone here can help me out :)
Kind regards,
Niels

Not sure of the IIS issue/solution, afaik special characters are not allowed in URLs, but the "Sitecore" way of resolving this is character replacement via config. This article explains config change required: SEO-friendly URLs in Sitecore
But essentially you need to add more encodenamereplacements in Sitecore config:
<encodenamereplacements>
...
<replace mode="on" find="æ" replaceWith="a" />
<replace mode="on" find="ø" replaceWith="o" />
</encodenamereplacements>
There is another thread with a similar issue: Sitecore issue on replacing danish characters in url

Related

The Web server is configured to not list the contents of this directory. asp.net vs 2012 error?

Got following Error:
HTTP Error 403.14 - Forbidden
The Web server is configured to not list the contents of this directory.
this is how I linked css file.
<link rel="stylesheet" type="text/css" href="~/styles/StyleSheet.css" />
i am using master page for first time. i did added master page in iss server.
i enabled the directory setting in my iss 8.0
Have you tried setting the following within your web.config file :
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
The Web server is configured to not list the contents of this directory
The keyword in the error is list.
That sounds more like you do not have a default document set up. If you don't have one, nor don't request a specific document (e.g. http://www.foobar.com/ or http://www.foobar.com/foo.html respectively) IIS will not "know" what to "serve" to the browser nor will it, nor should you expect it to, list the contents of that directory (instead).
See: Microsoft Support: Error 403.14
A Short Story Of A Lost Controller, And A Happy Ending
Let's say you have a controller called Data, in the project file /Controllers/DataController.cs. You can access it just fine via http://yoursite.com/data, which is handled by the DataController.Index action method.
Then, somehow, it breaks, and you start getting "The Web server is configured to not list the contents of this directory" when you visit this URL. Strangely, visiting /data/index still works! You try all the suggestions found online to make this work but can't seem to do it. What could it be?
Perhaps you ought to think about what the error means. It says that when you visit /data, it finds a directory there, but you aren't allowed to see the files in it. Setting aside the fact that your routing doesn't seem to work and it should, could there actually be a directory there?
Yes, there could! In your web project, you cleverly added folder /Data! This is a physical folder that takes precedence in the server's static routing rules (since you didn't rewrite those so physical files would be looked at after managed virtual paths).
The solution is thus to rename the folder, or rename the controller, one or the other. This will fix your problem quite speedily and you may then proceed on your merry way coding long into the night to the enveloping strains of techno Spanish mandolin trance music, with your trusty cat snoozing on your foot and the cold beverage of your choice beading up on the desk next to you!
The Ramesh Rajendran's answer must working, but you can use look at what is the modules your web application use and add in system.webServer tag on webconfig file to they use it. I had this error also in a test web application when I put it on Server IIS.
It's very strange not list the contents with the option enabled on IIS Web Server.
When you press Ctrl+F5, then IIS don't understand what to serve as you don't have any Default aspx file in your site , i recommend you to add a aspx file by going to Add>NewItem>Webform>
Note: remember to check the box at bottom right , "select from master page"
after selecting , save all the pages and just open your default.aspx file and you will surely see the reflected design as you did in master page.
Master pages are not aspx file but serve as a template for other webpages , so you cant just open master page.
Don't start the debugger while you are on the master page. EdSF pretty much summed up why.
In addition, you also may need to set a default start page(right click, set as start page).
You should define a default document value in web config and disable directory browsing.
<system.webServer>
<defaultDocument>
<files>
<add value="insertion.aspx" />
</files>
</defaultDocument>
<directoryBrowse enabled="false" />

Path to ISAPI filters with double back slash.

Recently i had an EPIserver site throing an error becaus it could not load the LoadLibraryEx for ISAPI-filter "C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet_filter.dll". I checked the IIS and the path looked very weird with 2 backslashes. Like this: "C:\Windows\Microsoft.NET\Framework\v4.0.30319\\aspnet_filter.dll" so i changes the path by removing one backslash and checking that the path was correct. Ths site worked.
Now i tried to install a new EPiSite and the error came up that it could not load the ISAPI filters but the path was with double backslash!
3.I read on the internet and found a forum thread about the double backs slash that said that it should be changed in the C:\Windows\System32\inetsrv\config\applicationHost.config. I checked and the path there was also with doubble slash so i changed it.
But now the site gives the same error but with only one back slash. It cant load it.
I dont understand ISAPI filters very well or the IIS, so i wonder if the backslash is something that should be there or if its a mistake, and ofcourse any help to reconfigure it to work is appreciated.
I recommend you to check your machine.config also for the filter path.
There might be some problem there.

500 Internal Server Error IIS7 Encoded url

Im using N2Cms and am looking in to some issues i have with it. It has a navigation panel on the left hand side that loads via ajax as you expand the tree.
The code that gets the childeren of the node calls an ashx file with some parameters. One parameter is for a path and contains slashes in it. For this reason it has been encoded.
.../cms/Content/Navigation/LoadTree.ashx?target=preview&selected=%252fhome%252fhelp-and-advice%252f
I have had no issues with this on my development server (running iis 7.5) but when deployed to our test server (iis7) the navigation fails to work.
Investigating this has shown that the above url gives a 500 error.
If i decode the url to
.../cms/Content/Navigation/LoadTree.ashx?target=preview&selected=/home/help-and-advice/
it works with no problems.
Unfortunately i cannot change the code that generates this as its a part of the n2cms source code and i am assuming it has been encoded for a good reason.
Does anyone know anything i can do either in my web.config to allow encoded parameters or something i can change on the iis server?
EDIT:
So this link seems to suggest that its doing this on purpose as a security mesure.
http://msdn.microsoft.com/en-us/library/ee656542.aspx
The suggested solution is to upgrade to .net 4.0 and add the following to the web.config
<configuration>
<uri>
<schemeSettings>
<add name="http" genericUriParserOptions="DontUnescapePathDotsAndSlashes"/>
</schemeSettings>
</uri>
</configuration>
Unfortunately this seems to have no effect.
Any Ideas why this doesnt work?
This could be the URLScan utility. URL Scan blocks URL's based on the rules in it's config file. It also has it's own log file, so you can tell for sure by looking at the URLScan log.
Do a google search for URLSCan default location.
It seems your url goes through 2 html encode.
Is there some url rewriting module active on your IIS7 server ?
OK, im getting somewhere with this.
When trying to find the error in the IIS logs and failing, then looking through many posts about failed tracing request and still not getting any errors in iis, i figured that the request was just not getting to IIS.
Looking back at the server error, there was a clue there too.
500 Internal Server Error. The request was rejected by the HTTP filter.
It is the firewall!!
We have disabled the HTTP Filter and now it works :)
I now need to investigate what this HTTP Filter was supposed to be protecting us against and are we secure now we have switched it off.

Need workaround for & in url, iis7

I am moving old asp.net website from windows 2003 to windows 2008 R2.
Some pages have '&' in url and it works fine on 2003 but on 2008 any '&' before '?' gives 'Bad Request'.
Those pages have serious impact on website popularity, 7% of all visits start here, so it is important to handle them properly without changing url.
Any ideas how to handle such urls on iis7 / asp.net 2.0?
PS: validateRequest doesn't work
Try adding the following in web.config:
<system.web>
<httpRuntime requestPathInvalidCharacters="*,:,\" />
...
</system.web>
Notice that I have removed & from the list of invalid characters in a path.
Here's a link that may get you where you want to to be, but if you read the details, I'd personally add this to the "do so at your own risk" category...take Microsoft's word for at least one of the "fixes":
Important If you enable this fix, you increase the attack surface of the application. You should not enable this fix unless the application requires it.
DWORD HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET VerificationCompatibility = 1
The others should be self-explanatory on risk just by the setting names (e.g. AllowRestrictedCharacters, ValidateRequest=False):
That said, you should think about updating those "legacy" urls and do a 301 Permanent redirect to account for your SEO/popularity...

Global.asax not firing for .aspx pages in IIS7

We run a link redirection service which can handle links thrown at it in various formats. One of these formats is to append the destination URL to the end of the link, for example
http://url.fwd/abcd/http://www.mydomain.com/page.aspx
This was working on a Windows Server 2003 / IIS6 box for the last two years, but now we're trying to move to a Windows Server 2008 / IIS7 setup and its not working anymore.
I've read about the problem with colons in the URL but it doesn't affect pages not ending in '.aspx'. For instance,
http://url.fwd/abcd/http://www.mydomain.com/page.php
would redirect fine.
http://url.fwd/abcd/http//www.mydomain.com/page.aspx
also works fine (note the lack of a second colon). Despite being the wrong URL, it does get handled by our URL forwarding system, which uses a custom 404 page. On the old system, we had a similar problem, so a method was written in Global.asax > Application_Error specifically to handle the '.aspx' case, and it worked fine.
On our new server, the Application_Error never gets thrown in Global.asax. Instead, I get a System.NotSupportedException - "The given path's format is not supported". This System.NotSupportedException is the exact case we handle in the Global.asax page, so it's definitely not being fired.
I've changed the registry keys indicated in several forum posts,
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ASP.NET VerificationCompatibility=1
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP|Parameters AllowRestrictedChars=1
I've tried changing the Handler Mappings settings for .aspx.
I've tried setting the App pool to use classic mode instead of integrated, but this causes a completely different error where static content such as images and CSS do not display at all. I've checked that static content is enabled in the windows features, and it is.
Under classic mode, the '.aspx' request throws two Bad Request errors with absolutely no information whatsoever. The code of the error page I get is literally
Bad Request<html><body>Bad Request</body></html>
UPDATE: I've changed the static file Handler Mapping to the form found in this page
http://improve.dk/blog/2006/12/11/making-url-rewriting-on-iis7-work-like-iis6
However, as the author rightly points out, this is a hack and not the correct way of doing things under IIS7. It also only fixes the static file problem in classic mode. '.aspx' pages still throw an error under classic mode.
Any thoughts or input would be greatly appreciated at this point.
IIS 7 Solution
The easy solution in IIS 7 is to add a setting in your web.config file to tell IIS to process all requests through your Global.asax events. Just add or change this section in your web.config to enable requests:
<system.webServer>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
In my case, I was publish my site in production and I miss copy to server App_global.asax.compiled file. For this reason was not fire the Events inside Global.asax.
Hope anyelse help this tips, I lost 8 hours seeking.

Resources