2
I have an all dynamic system where I get all my paths, controllers, views and areas from the BD.
My problem now is when I try to access a page it returns to me too many redirects response
.
What happens in this area is:
- User fills in a form;
- The form is posted via AJAX and the user is redirected via Jquery;
- The user then makes a schedule or views the voucher;
If the user tries to return the home page either by using the back button or by changing the Url it drops into a loop of redirect, this is because on the scheduling and voucher pages I have a Session check, if it is null I do the redirect back to the start(form), this is the redirect check:
if (TempData["LeadID"] == null || Session["UnidadeCE"] == null)
{
Response.Redirect( HelperMethods.CreateLink( Request.RawUrl.TrimStart( '/' ).Split( '/' )[0] ) );
Response.End();
return null;
}
Now, what’s weird is that when he tries to change the page RouteBase
tries to retrieve the information from this new URL and at this point for some reason he ends up taking the same page, scheduling instead of the form page and then starts the whole looping.
The worst is that this only happens the first time, for example:
I filled out the form, dropped in the schedule and went to the voucher, tried to return drops in loop, hope and give a refresh, loads the page normally.
Since the code is kind of extensive I put it in a bin: http://pastebin.com/yTdWKMp4
And there are also requests headers:
HTTP/1.1 302 Found
Cache-Control: private, no-store, max-age=1
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Expires: Wed, 25 Nov 2015 19:01:23 GMT
Last-Modified: Wed, 25 Nov 2015 19:01:22 GMT
Etag: ""
Location: /teste-lp
Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-UA-Compatible: IE=Edge,chrome=1
Date: Wed, 25 Nov 2015 19:01:22 GMT
Content-Length: 115
HTTP/1.1 200 OK
Cache-Control: private, no-store, max-age=1
Content-Type: text/html; charset=utf-8
Content-Encoding: gzip
Expires: Wed, 25 Nov 2015 19:02:10 GMT
Last-Modified: Wed, 25 Nov 2015 19:02:09 GMT
Etag: ""
Server: Microsoft-IIS/8.0
X-AspNetMvc-Version: 3.0
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
X-UA-Compatible: IE=Edge,chrome=1
Date: Wed, 25 Nov 2015 19:02:12 GMT
Content-Length: 6852
EDIT
After a lot of debugging and checking of vars ( I have about 6k routes inside pageList ) I discovered that the problem is being to check the value and update the variable.
On line 128 of the archive of the Pastebin I get a list of routes and look inside it for the route that interests me, on line 167 is the case of the voucher, I check if it has this name in the URL and look for the correct route, as this is a route "generic" for the three areas ( form, scheduling and voucher ) I need to put the Controller
and Action
that I want. At this moment I am updating a local variable, but I end up updating the parameter as well pageList
.
I’ve also tried to put another variable pages
within line 128 method, copy the pageList
for her and then carry out the search within her. the pageList
also ends up being updated as well as Cache, line 202.
What could be generating this ?