asp.net mvc - MVC RedirectToAction calls Session_Start() in global.asax -
i calling redirecttoaction method call action method controller clears session data debugged in global.asax , found out when ever call redirecttoaction calls session_start() method. don't know how session start called. here web config code form , session tag
for session tag
<sessionstate mode="inproc" customprovider="defaultsessionprovider"> <providers> <add name="defaultsessionprovider" type="system.web.providers.defaultsessionstateprovider, system.web.providers, version=1.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" connectionstringname="defaultconnection" /> </providers> </sessionstate>
and form tag
<authentication mode="forms"> <forms loginurl="~/controllername/actionname" timeout="2880" /> </authentication>
this "~/controllername/actionname" same method wher calling "redirectoaction"
just info trying if found cookies user redirected home page login page directly
both action methods in different controller , in different areas. here code uses "redirectoaction" method
public class logincontroller : controller{ public actionresult index() { if (request.cookies["username"] != null && request.cookies["password"] != null) { fillloginsession();//fills session user data ex. session["user_id"] = 1; return redirecttoaction("index", "home", new { area = "home" }); } }}
and here action method in controller redirecting.
public class homecontroller : controller{ public actionresult index() { return view(); }}
ok got solution problem. calling this
response.cookies.add(new httpcookie("asp.net_sessionid", ""));
before initializing session method. in iis key "asp.net_sessionid" used store session in cookies. cleared reinitialize when ever redirect new page.
Comments
Post a Comment