MVC ::Session Variables Called From The Owning Controller?

Feb 19, 2011

I'm calling an action from another controller using this code

[Code]....

But inside "ApproveOperation" action, I needed the Session variables. It seems when I called it from another controller (not the owning controller), the Session variables can not be accessed (null value).How can I get the same Session variables just like it was called from the owning controller?

View 4 Replies


Similar Messages:

Collect 2 Variables From One Hyperlink, And Use Those Variables In The Page_load To Set As Session?

Aug 8, 2010

i am trying to collect 2 variables from one hyperlink, and use those variables in the page_load to set as session. but i don't know how to collect those 2 variables

such :

<a href="javascript:;" onclick="wsChangeColor('mainData', '#FF0000','#FFE4E1');return false;" title="Change color" id="red">1</a>

i would like to collect '#FF0000','#FFE4E1' or direct set '#FF0000','#FFE4E1' to string then send to pageload, how can i do this by only clicking on it ?

View 1 Replies

MVC :: How To Check In Controller Where The Maproute It Was Called

Nov 29, 2010

This two maproute maps to the same controller, how to check in the controller which maproute it was called from?

routes.MapRoute( _
"Categories", _
"category/15", _

[code]...

View 5 Replies

MVC :: Controller Not Called From Actionlink Or RedirectToAction

Mar 4, 2011

I am new to MVC2 and have hit a wall. When I use an action link to jump back to a previous page that I have already been on, my controller is not called but the page is rendered correctly. Is this some sort of caching that I am not aware of? This also happens with a RedirectToAction call from another Controller. rfm is the Model...

return RedirectToAction("Search", rfm);

Here is the actionlink...

<%: Html.ActionLink("Search", "Search", "Reference")%>

View 3 Replies

Controller Method Not Always Called From $.getJSON Request?

Mar 9, 2010

I have a controller method that returns a jSON object and in one calling situation, it works and in another calling situation, it does not work. When the URL in my browser is this:

http://localhost:65247/Client -- it works.

But, when my url looks like this:

http://localhost:65247/Client/UserAdmin?id=6 -- it DOES NOT work

In a nutshell, clients have users. From within the client, I wish to work on a specific user (this is the UserAdmin view). In this case, the client id is 6. From within the UserAdmin view that was launched with Id=6, I then wish to select a user from a dropdown. The idea was to use javascript and $.getJSON to fetch data for the specific user so as not to have to refresh the entire page. I use this approach in other parts of the app. The only difference I can see is with the URL in the browser. It would appear the presence of parameters via the '?' is futzing things up a bit.

View 1 Replies

.NET MVC Controller FileContent ActionResult Called From JQuery?

Feb 10, 2010

I have a controller method "SaveFile" that attempts to download a binary stream to client's PC using the FileContentResult. If I make the call as a post from the controller corresponding view everything works OK. I want to call the same controller method "SaveFile" from a jquery function via an .ajax call, when I do the function returns an error and the responseText is the contents of the file to be written. What would I have to do to get the same behavior from a jQuery function as if the MVC framework handled the call via the submit button? Or an alternate solution would be to determine how can I catch the browser's download dialog close event.

View 1 Replies

MVC :: Session Vs TempData / How To Persist Values From Controller To Controller

May 30, 2010

I have a filter on my MVC web site. I display some records in a few different controller actions but when moving from one action to another I want to apply those filter values.

How can I persist values from controller to controller?

Should I use Session? TempData?

I am using Structure Map for IOC.

Maybe I could have a class that contains a Property for each Session Value that I use in my application and inject it on the controllers that need session?

View 10 Replies

MVC :: Can't Reach Controller - Javascript Library And Method Called From View

Jul 23, 2010

I have a javascript library and in there i have a method that is called from my view. Here it is:

<li><a href="javascript:void 0" onclick="deleteAll('image', '<%= ViewData["FileGroupId"]%>')"><div><%=GetGlobalResourceObject("default", "Delete_all") %></div><div></div></a></li>
and here is my js code in the javascript library:
var deleteAll = function(module, groupId) {
jConfirm(_deleteConfirmAll, _deleteAll, function(r) {
if (r) {
showProgress();
$.ajax({
cache: false,
type: "POST",
url: _baseUrl + "/" + module + "/deleteall/" + groupId,
success: function(msg) {
if (msg == '0') {
location.href = _baseUrl + '/' + module;
}
else {
jAlert(msg, _errorTitle);
}
hideProgress();
}
});
}
});
}
My problem is that i cant reach my controller. Here is my controller code:
#region common methods
List<.CMS.Core.File> GetList(int groupId)
{
List<CMS.Core.File> list = new List<CMS.Core.File>();
CMS.Core.FileFilter filter = new CMS.Core.FileFilter();
filter.GroupId = groupId;
int res = CMS.Core.File.Search(_connection, filter, ref list);
return list;
}
#endregion
public ActionResult DeleteAll(int groupId)
{
List<CMS.Core.File> list = GetList(groupId);
foreach (File item in list)
{
item.Delete();
}
return Json(list);
}
And at last her is my Index method
public ActionResult Index(int? id)
{
if (Request.IsAjaxRequest())
{
JsonPaging paging = new JsonPaging();
int offset = 0;
int page = 0;
if (!String.IsNullOrEmpty(Request.QueryString["page"]))
{
Int32.TryParse(Request.QueryString["page"], out page);
}
if (page > 0)
{
offset = (page * paging.PageSize) - paging.PageSize;
}
FileFilter filter = new FileFilter();
filter.Deleted = false;
filter.MaxRecords = paging.PageSize;
filter.Offset = offset;
if (!String.IsNullOrEmpty(Request.QueryString["keywords"]))
{
filter.FilterType = FilterTypes.AND;
filter.Name = Request.QueryString["keywords"].ToString();
}
if (!String.IsNullOrEmpty(Request.QueryString["sort"]))
{
filter.OrderBy = Request.QueryString["sort"].ToString();
if (!String.IsNullOrEmpty(Request.QueryString["direction"]))
{
filter.OrderBy = filter.OrderBy + " " + Request.QueryString["direction"].ToString();
}
}
if (id > 0)
{
filter.GroupId = id.Value;
}
List<CMS.Core.File> items = new List<CMS.Core.File>();
int results = CMS.Core.File.Search(_connection, filter, ref items);
foreach (CMS.Core.File current in items)
{
JsonItem item = new JsonItem();
item.Id = current.Id;
item.Name = current.Name;
item.ImageText = current.ImageText;
item.Aperture = current.Aperture;
item.TakenOn = current.TakenOn;
item.Camera = current.Camera;
item.ExposureTime = current.ExposureTime;
item.FocalLenght = current.FocalLenght;
item.Tags = current.Tags;
item.Url = current.Url;
item["Active"] = current.Active.ToString();
item["Created"] = current.Created.ToString();
paging.Items.Add(item);
}
return Json(paging, JsonRequestBehavior.AllowGet);
}
else
{
ViewData["FileGroupId"] = id;
return View();
}
}

View 2 Replies

State Management :: Session And Session Variables Not Stable In Development Server?

Oct 11, 2010

I use some session variables to get the job done(shopping cart, etc) but it is not stable..manytimes I get no items in session object and other times(refreshing the page) I get missing data...I downloaded the entire site code to my local pc and debugged it and run it succesfully without any session data missing...When I run it in the server, I get bad session again: no products in shopping cart or products with missing quantities...

The same website runs smoothly in our production server too....The problem is with our development server...

View 2 Replies

State Management :: Session Variables And Tabs / Is There A Way To Reset The Session Variable

Nov 11, 2010

I have some code in my page load event where I just want to fire once when the user opens the Browser. The only issue is if you open a new tab with the same website the session variable does not reset. Is there a way to reset the session variable when you open a new tab or do you have to take the whole web browser down for it to clear the session variable.

In Global Page:

[code]....

View 2 Replies

MVC :: Controller Base Class Initialize() And OnActionExecuting() Not Called When Unit Testing?

Nov 16, 2010

I'm using a simple base class for my controller that sets a piece of ViewData and makes use of the HttpContext. My understanding is that I need to put this code in Initialize() or OnActionExecuting(). I tried both, but believe Initialize() is what I want.

This works when running the app in VS just fine.

I wrote a unit test that calls the action and checks the ViewData for the expected value. When unit testing, neither method is called.

View 2 Replies

How To Pass All The Local Variables In One Controller To View

Jan 16, 2011

In asp.net mvc3, I've got a few local variables in one of the controller, is there any neat way to pass all these variables to view? Something like "locals()" in python?

View 1 Replies

IIS InProc Session Variables Randomly Not Written To Session

Nov 12, 2010

There are reams of info out there about things causing InProc session to drop session objects, but that's not what's happening here. We're missing individual variables within stable InProc session objects, and are not sure whether they're not being written or being lost after a successful write. I've confirmed with WinDBG that the sessions are live and contain some, but not all, of the data written to them.

Guid g = System.Guid.NewGuid();
this.Context.Session.Add(g.ToString(), result.ImageData);
output.Write("<img src="display.aspx?id=" + g.ToString() + "">");

This code is pretty straightforward, and it works flawlessly in Test. In Production, under heavy load, though, it fails ~1% of the time. If Mr Smith visits the site and attempts to display 4 pieces of image data, 2 of them might be saved in his session and two of them be lost. The InProc session object for Mr. Smith exists. The traffic logs show he clicked 4 times, each with a different id param. But there are only 2 guids in his InProc session object, instead of 4. The 2 session objects we did capture do correspond to 2 of the id's shown in the traffic log (his 1st and 3rd clicks.) The traffic logs for his 2nd and 4th clicks, though, show a guid id that's not in his InProc session object.

Lines 1&3 of the above code obviously worked for those 2nd and 4th clicks, or he'd not have had the id in the URI for him to click. Line 2, however seems to have failed silently in some way. If any exception had been thrown, I'd expect we'd not ever have arrived at line 3. I can't see any way for the user to receive the guid id, but the session to fail to have it. The other possibility is line 2 worked successfully, but the variable later disappeared, how I cannot even imagine.

Details:
ASP.NET v3.5
IIS 6
No Web Gardening

We're running a web farm, but users constantly return to the same server. I'm researching now whether there's any way users might be slipping off to the other server.

View 2 Replies

MVC :: Radio Button Sets From The Controller Without Passing 15 Different Variables To The Post Method ?

Aug 27, 2010

I'm fairly new to MVC and admittedly don't fully understand how data is passed between Views and Controllers. That said, here is my issue.

I am working with C#. I have a page which has a list of items. Each item has a radio button set of three associated with it and there are 15 of these sets on the page. Thus I have radio1, radio2....radio15, etc. Each of these has value 0, 1, or 2 upon submit. I can't seem to understand how to get the information out of these radio button sets from the controller without passing 15 different variables to the post method in the controller which is associated with the view; ie passing Int32 radio1, Int32
radio2,.., Int32 radio15, etc.

I tried using ViewData["radio"+i] in a loop to access the value of each radio button set, but this, apparently can only be used to pass data to the View from the Controller and not the other way around.

View 6 Replies

Session Being Called Only Once?

Mar 22, 2011

i read that whenenver you call an instance of the your site the session_start is called. I am using the following code to create a visitor counter

void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application.Add("Myvariable", 0);
}

[Code]....

Hence when I run the program the output is "User No:1"

and i copy the url to another firefox tab and paste it there the output is still the same. Isnt it suppose to increment. My session _start is not being called why ?? I was reading a tutorial in which it is being incremented.

View 2 Replies

Web Forms :: How Come A Null Session Value That Is Called

Sep 13, 2010

how come a Null session value that is called, doesn't get directed to the Custom Error Page?

View 4 Replies

Will Application_end Be Called When All Users Session End

Aug 5, 2010

will the application_end event in global.asax gets called when all users end there session?

was it like this in the past maybe?

View 1 Replies

Next SessionID After Session.abandon Is Called?

Jan 25, 2011

To avoid session fixation/hijacking we are heeding the common advice to create a new ASP.Net session for a user after authentication. Sounds simple enough. When a user authenticates we call Session.Abandon() the session ID cookie Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", "") then redirect the user.

However, how do we know on the new page that the user has logged in? We cannot check a session variable because there are none, we just started a brand new session.

I would swear, though I cannot find it now, that on this site someone explained how you can abandon a session and then get the next subsequent session ID. This way you could store that information. Then on the "Start Page" a new session would begin and that page could look up the old Session based on the new ID and validate that a user logged in.

So, are there any masters of the ASP.Net Session classes that know how to do this?

View 2 Replies

Web Forms :: Usercontrol Which Needs To Work Slightly Differently According To The Attributes Of Its Owning Page?

May 10, 2010

I have a usercontrol which needs to work slightly differently according to the attributes of its owning page.Is there a way to determine the owning page from within the user control?

View 1 Replies

Where Are The Session Variables Saved

Dec 24, 2010

Where exactly are session variables saved? Cookies? Server memory? Again where are Application variables saved?

View 3 Replies

How To Clear The Session Variables

Mar 22, 2010

I need to clear all sessions at the end of my application, to many to list individually.

So I have found the following ways, but which is best?

Session.Clear();
Session.Abandon();
Session.RemoveAll();

And then the specific way

Session.Remove("variable");

View 5 Replies

How To Set Cookies And Session Variables

Jan 27, 2010

Am trying to design login page for my website and I am looking for methods other than forms authentication. The way in which I am trying is to have a table in the database that stores user information and check for the user validity.

The point where I get struck is how do i set cookies and session variables and how will I carry it through out the system. Can anyone tell/suggest me where I can relevant material so as to move forward. And also is my idea of negating traditional forms authentication and going for a model I described, is it good also does any other better method exist?

View 1 Replies

MVC :: Session Variables For Authentication?

Jul 30, 2010

I want to password protect an area of a website by a login/registration form.

I'm using session variables to check wheter the user is logged in or not. I already have a database with users/passwords... so I thought that the membership approach wasn't an option... (correct me if I'm wrong)

in the constructor of the controller of the area I want to protect I've added the following:

[Code]....

but this throws an error:

Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. review the stack trace or more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

[Code]....

Line 28: this.productsRepository = productsRepository;Line 29: Line 30: if (Session["user"] == null)Line 31: RedirectToAction("List", "Products");Line 32: }

View 2 Replies

MVC :: Accessing Session Variables

Nov 10, 2010

I am working on an asp.net mvc app.Right now I am looking for the best solution to access session variables.
Is it oke to make a static class to get session variables, like:

[Code]....

And so on for other session variables.Is it allowed to access session variables in static model classes ?

View 2 Replies

Manage One's Session Variables?

Mar 25, 2010

In my .NET web app, I keep basic user info in a user session object. I also usually keep a director class in the session; which is basically just has info about whatever thing it being worked on on that screen (like a customer id).

I am trying to keep from adding a ton of sessions. I also want to make sure at any given time ONLY the sessions that are necessary are in memory.

This means I need an effective way of managing my session variables.

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved