0

I'm using MVC 5 with Identity 2.0 for security. When I start the application it displays login page (without layout probably because I'm returning partial view). When I use return View() instead of return PartialView() it gives me following error;

HTTP Error 404.15 - Not Found The request filtering module is configured to deny a request where the query string is too long.

I enabled both windows and Anonymous authentication of website but it is not working. My action for login is

 [AllowAnonymous]
 public ActionResult Login(string returnUrl)
 {
     ViewBag.ReturnUrl = returnUrl;
     return PartialView();
 }       
jruizaranguren
  • 12,679
  • 7
  • 55
  • 73
Ahsen
  • 386
  • 4
  • 18
  • is the url for the returnurl very long? This is usually placed in the querystring. When the returnurl is too long (i.e. /home/products/all/and/more/clothes/sizes/10/to/12/etc....) then the total length of the querystring is too long. There is a setting to allow a longer querystring here: http://stackoverflow.com/questions/11636386/how-to-configure-the-web-config-to-allow-requests-of-any-length (if this is the problem) – Michel Jan 13 '15 at 10:38
  • @Michel my returnurl gets weird. It becomes http://localhost:8396/Account/Login?ReturnUrl=%2FAccount%2FLogin%3FReturnUrl%3D%252FAccount%252FLogin%253FReturnUrl%253D%25252FAccount%25252FLogin%25253FReturnUrl%25253D%2525252FAccount%2525252FLogin%2525253FReturnUrl%2525253D%252525252FAccount%252525252FLogin%252525253FReturnUrl%252525253D%25252525252FAccount%25252525252FLogin%25252525253FReturnUrl%25252525253D%2525252525252FAccount%252525252 – Ahsen Jan 13 '15 at 11:37
  • Why does it become so long. It only happens when I return View from controller. When I return PartialView from controller it works but doesn't come with layout – Ahsen Jan 13 '15 at 12:23
  • It has 2269 characters. It seems like an infinite loop is making this url problemtic – Ahsen Jan 13 '15 at 12:24
  • What happens when you navigate to the root of the site at startup? Do you get redirected to `localhost/account.login?returnUrl=/` ? – Michel Jan 14 '15 at 10:23
  • No I couldn't redirect. I removed [Authorized] attribute from the controller and it started working :) – Ahsen Jan 14 '15 at 12:11

1 Answers1

1

your issue it's not the MVC code it's more an IIS configuration take a look at the following link

http://www.iis.net/configreference/system.webserver/security/requestfiltering/alwaysallowedquerystrings

BRAHIM Kamel
  • 13,492
  • 1
  • 36
  • 47
  • Thanks for your reply. I'm getting this error on debug mode, website is not hosted on IIS. It seems like it stucks in an infinite loop and returnurl gets long and long. I tried to do it in web.config in system.webserver/security/requestfiltering/requestLimits@maxQueryString – Ahsen Jan 13 '15 at 12:19
  • query string contains 2269 characters and is like: http://localhost:8396/Account/Login?ReturnUrl=%2FAccount%2FLogin%3FReturnUrl%3D%252FAccount%252FLogin%253FReturnUrl%253D%25252FAccount%25252FLogin%25253FReturnUrl%25253D%2525252FAccount%2525252FLogin%2525253FReturnUrl%2525253D%252525252FAccount%252525252FLogin%252525253FReturnUrl%252525253D%25252525252FAccount%25252525252FLogin%25252525253FReturnUrl%25252525253D%2525252525252FAccount%2525252525252FLogin%2525252525253FReturnUrl%2525252525253D%252525252525252FAccount%252525252525252FLogin%252525252525253FReturnUrl%252525252525253D%25252525252525 – Ahsen Jan 13 '15 at 12:20
  • Why does it become so long. It only happens when I return View from controller. When I return PartialView from controller it works but doesn't come with layout – Ahsen Jan 13 '15 at 12:22