Asp.net MVC 3 HttpContext.Current.Session null - asp.net-mvc-3

I am working on Asp.net Mvc3 application and using custom authentication using IPrinciple, IIdentity
and storing the authenicated user details in HttpContext.Current.Session (SimpleSessinPessister staic class).
After navigating between diffrent actions /views (in same controller) (using RedirectToAction) HttpContext.Current.Session becomes null.
Another observation is that soon We generate PDF using miscrosoft.reportviewer this HttpContext.Current.Session becomes null and application is forced to relogin.
If `HttpContext.Current.Session becomes null then TempData is also becomes null ?
Thanks in advance. Jms

Related

MVC 5 ajax not working in default project

i have created a default MVC 5 project. i used Entity Framework 6. I created a simple person class with Id and Name as a model. Then i generated CRUD operation for it using MVC 5 template after running the code first migration. i implemented a delete functionality everything is working fine.
but when i copied the same code other MVC project. but this project contains some additional css and js. whenever i click on delete or any other operation page is posting back. i want to know why it is happening and why default project has every thing enabled with Ajax.
what i am missing in this project
To enable ajax helpers:
Install-Package microsoft.jQuery.Unobtrusive.Ajax

Confusing about using angularJS with Codigniter

I'm new to front-end MVC and I decide to create a SPApplication then I found this angularJS. Of course, other MVC as well but I prefer angularJS.
Ok, my questions here.
Before this, I normally store my MVC files at backend MVC folders which is codeigniter view folder if it is html partial or page.
So is it the time to move the backend MVC to frontend?
Another question, what is codeigniterRest? do I need it to use with angularJS?
No, the backend MVC in CodeIgniter and the frontend MVC in Angularjs have a separate role totally.
The backend MVC will handle the data sent to the app by your frontend.
The frontend MVC in angularjs will receive a response (usually in json) from the backend MVC in CI and handle that data using its views and controllers.
So your Single Page App will consist of all the bells and whistles of CI + 1 view page (or more if you break that page into partial includes) that will store the angularjs app in it.

ASP.NET MVC3 client side state management

I have 2 Views in my MVC3 application. One View creates a cookie via JavaScript, and I'm trying to access it in another View.But it shows up as 'undefined'. Why so? Also, I wanted to know if there are any client side state management options in ASP.NET MVC3 besides Cookies?
You can use HTML5 local storage:
window.localStorage["test"] = "Hello World!";
I figured out a workaround (not exactly what I was looking for though) for the problem.I used the Session object to store my data and then retrieved the session in a string variable under #{ } block in my razor View. I then accessed the C# variable in my JS code.

how to use object(return from controle) in jquery/javascript with asp.net mvc3

I am working on asp.net mvc3 asynchronous process with ado.net
In my application After updating user his profile data - next time User login to his account, in that time I want to display his default profile data(if not null) into his profile page.
1)In this scenario I unable to display user default data in dropdownlist
I am using html dropdownlist()
2)how to communicate data which is returned from control to view with jquery(give me sample ex)
Can you tel me anyone how to display user default data after update his profile. Thank you for advance...
You can return data using json format and then parse it to javascript object: http://api.jquery.com/jQuery.parseJSON/

ASP.NET MVC 3 validation: Are the DataAnnotation attributes useless when JavaScript is disabled?

Scott Guthrie blogged about ASP.NET MVC 2: Model Validation little over a year ago and in his post, the controllers were decorated with calls to ModelState.IsValid-method. Since then we've had the ASP.NET MVC 3 which included quite big changes to the validation.
But has the requirement to call the ModelState.IsValid still stayed the same? Are all the DataAnnotation attributes useless if the site visitor has disabled the JavaScript and the site developer has forget to check the value of ModelState.IsValid?
If yes, is there a way around this? Is it for example possible to register a global filter which always remembers to check for the model's validity event if the coder doesn't?
The client side validation features would be turned off. This is why you must never rely only on client side validation. It would not affect the model binder which uses the annotations on the server. Here is the relevant text from that blog post...
Because the action method accepts a
“Person” object as a parameter,
ASP.NET MVC will create a Person
object and automatically map the
incoming form input values to it. As
part of this process, it will also
check to see whether the
DataAnnotation validation attributes
for the Person object are valid. If
everything is valid, then the
ModelState.IsValid check within our
code will return true – in which case
we will (eventually) save the Person
to a database and then redirect back
to the home-page.

Resources