Web Forms :: HttpContext.Current NULL When Using .NET ReportViewer And An ObjectDataSource
Mar 10, 2010
I have an ASP.NET Web Forms app using Entity Framework in the data layer. I've recently changed the app over to use one Object Context per request as per this post. It works great for the entire application except for any page which uses a ReportViewer to display something.
I've noticed that it fails when trying to get an instance of the [Code].... from the [Code].... collection because [Code]....
is null.
Microsoft.ReportViewer.WebForms.dll and Microsoft.ReportViewer.Common.dll can also be seen in the call stack each time it fails. The reports each use one or more ObjectDataSources to retreive data.
Based on this I'm assuming that the ReportViewer is somehow to blame, but i have no idea why. I would need some way to dispose the ObjectContext after it had been used by the report at the very least.
View 1 Replies
Similar Messages:
Feb 5, 2010
Is it safe to always assume that HttpContext.Current will be non-null in Application_PreRequestHandlerExecute?
EDIT: Assuming ASP.NET webforms (not MVC).
View 2 Replies
Aug 20, 2010
I am getting HttpContext.Current.Session is null.Will this be a problem if we have application hosted in web farm.
View 1 Replies
Jan 17, 2011
i'm storing in HttpContext.Current.Session current user, SiteUser is single-tone class that presents current active siteuser, and when he logged i'm creating new SiteUser() in controller and in constructor adding him to the session:
[Code]....
then, with every request to the server services i'm check is user available in session:
[Code]....
otherwise i'm generate non-auth-user exception and redirect him to the logon page. but sometimes HttpContext.Current.Session[sessionKey] is null, but HttpContext.Current.Session doesn't null and FormsAuthenticationTicket is available and Expired property is also false. can somebody help me, why HttpContext.Current.Session[sessionKey] can be null?UPDi have downloaded symbol tables of source .NET Framework and set breakpoints at SessionStateItemCollection on changing collection items. and i resolved some mistakes:1) all collection items are null — "culture" is setting up after2) it happens at the session end eventi can't understand how it can be, because at web.config session timeout is set 20
View 20 Replies
Nov 15, 2010
I'm using VS2010 and created a simple asp. web forms application, using Development Server to test it. I try to store user data - queried from sql server - in the session, since I don't want to access database in every request. I'm using the 'Application_AuthenticateRequest' and the 'Session_Start' methods.
First round:
AuthenticateRequest called. The following code ran:
[Code]....
The _current variable is a private static field published through a static property. In the first round the Session is null, and I think it's ok because the Session_Start not called yet. The Session_Start looks like this:
protected void Session_Start(object sender, EventArgs e)
{
Session["EMPLOYEE_DATA"] = EmployeeFactory.Current;
}
In the next round the Session_Start is not called of course but in the AuthenticateRequest I can't access to the session. The HttpContext.Current.Session is null and the this.Session reference throw a HttpException says the "Session state is not available in this context".
However I can access the Session from any of the page_load events but it's a bad practice I think that I put authentication every page_load.
View 1 Replies
Aug 19, 2010
We've got a fairly large, complex web application that uses Forms Authentication to authenticate users. Throughout the application we store and retrieve information about users in the Session object, and in some cases in cookies. In a couple places we check for the existence of the context, and if it's null we send the user back to the login page to re-establish the session. Just a quick run-down of this web app: C#, .NET 3.5, IIS 6, ASP.NET State Service to manage sessionAs for the session timer, we use our own home-grown timer, which is basically a client-side timer, which is backed up by a check to the SQL database to see when their last activity was. This seems to work well for us. It's not perfect, but it allows us to notify the user before the session times out, and allows us to be certain we're not logging a user out before their 60 minutes of inactivity is up.What's happening is that certain users are being logged out after just a few minutes. We've eliminated the timer as a cause and believe what's happening is the HttpContext.Current is null, so the user is logged out. We do not know why the HttpContext.Current is null, and I understand there are many reasons that may occur. What I'm trying to figure out is, is there any way to re-establish the context once it is null? If not, is there anything I can do at this point other than have the user login again? We're also trying to figure out a better way of managing user information (preferences, roles, flags, history, etc), but everything needs context to use, right? Cookies, sessions, cache, etc. all require a response or request, correct? hope this makes sense, because I really need help with this. I've searched the forums here, and found many posts about HttpContext.Current going null, but not a lot of solutions for this...
View 14 Replies
May 20, 2010
1. SetSession.aspx page sets value for a session variable and redirects to default.aspx page using Response.redirect() code.
2. Default.aspx page tries to create an object of class in app_codecommon.cs file.
3. In app_codeCommon.cs file, I am trying to access the session variable set in step1 using HttpContext.Current.Session object.
but step 3 gives error that object reference not set to an instance. as HttpContext.Current.Session is null.
I surf abt it on net, and seems to be problem with asp.net framework.
View 1 Replies
Mar 11, 2010
I have a static class with serveral static methods. In these methods, I'm trying to access the current thread's context using HttpContext.Current. For example:
var userName = HttpContext.Current.User.Identity.Name;
However, when I do that, I receive a NullReferenceException, the infamous "Object reference not set to an instance of an object."
View 3 Replies
Jun 1, 2010
I have a simple web form with a dropdownlist and a ReportViewer. I would like to dynamically change the report within the viewer when the user makes a selection in the dropdownlist. I think I need to alter the ObjectDataSource that the ReportViewer is using. I've tried a few things without success.
View 2 Replies
Nov 23, 2010
i'm using an example in which i can fake the session.It's for use in a unittest of a mvc controller.In the test i create a controller and then i do this:
FakeHttpContext httpctx = new FakeHttpContext(null,null,null,null,mSessionItems );
ControllerContext ctx2 = new ControllerContext(httpctx,new RouteData(), target);
here mSessionItems is my session and target is my instance of a controller,and indeed, when i'm in a controller reading this.ControllerContext.HttpContext.Session, i have a session, great!but.... i also read the session outside the controller, and there i use HttpContext.Current.Session, and that is null (or actualy, the HttpContext.Current is null).
View 1 Replies
Oct 27, 2010
I was under the impression that you could use the HttpContext.Current.Items collection to pass information between pages but it doesnt seem to workLets say i have a Page1 ButtonClick, the button click handler stores a value in the collection like so; HttpContext.Current.Items("Test1") = "Test"Then i do Response.Redirect("Page2.aspx").In the Form_Load of Page2, HttpContext.Current.Items("Test1") contains nothing. Why does this not work when its all part of the same postback?This would be perfect, because i wouldnt need to worry about clearing the values between requests because they would automatically get cleared each time the page was posted back.
View 5 Replies
Jul 28, 2010
In an asynchronous process, I need to get the name of the domain/server the web application is running on. But in that situation HttpContext.Current is not available, so I cant use HttpContext.Current.Request.ServerVariables("SERVER_NAME").
View 7 Replies
Aug 5, 2010
I'm wondering how HttpContext.Current gets assigned a unique instance for every request considering it's a static object?
View 2 Replies
Apr 1, 2010
I have a data object where one of the properties is a collection of another data object. I never really figured out how to map this to a GridView, but I came up with a workaround. Now I am stuck and cannot figure out any way to do this in a ReportViewer.
Here is how I solved the GridView issue:
Say we have these objects:
public class BoysWithToys : List<BoyWithToy>
{
}
public class BoyWithToy
{
string FirstName { get; set; }
string LastName { get; set; }
int BoyNumber { get; set; }
List<Toy> FavoriteToys { get; set; }
}
public class Toy
{
int BoyNumber { get; set; }
string Toy { get; set; }
}
What I wanted to do was to map BoysWithToys to the GridView and present one GridView row per BoyWithToy record. Where there was more than one FavoriteToys record I wanted to list them in a bulleted list in the FavoriteToys column. I accomplished this by calling RowDataBound() for the GridView, casting the e.Row.DataItem to BoyWithToy, then looping through all of the FavoriteToys and adding each Toy to a bulleted list, then setting the column's text to that list.
I have no idea how to accomplish anything similar in ReportViewer. If I simply drag the BoysWithToys DataSource to the designer and run it, the FavoriteToys column shows '#Error'.
View 3 Replies
May 4, 2010
As per title. I want to be able to save some data in a cache object but this object must be available to all users/sessions and can expire.What is the best method to achieve this in a asp.net web app?
View 2 Replies
Jan 20, 2011
I have some code that works fine when I need to delete some image files from a directory on my web server:
Dim ImageURL As String = dsImages.Tables(0).Rows(iImgRow).Item("ImageURL")
Dim physicalName = Server.MapPath(ImageURL)
oUpload.DeleteFileFromServer(physicalName, iAdid, iImgID)
.but I am running into a problem when a maintenance task running in a separate thread at set intervals determines that files like the above need to be deleted:
Dim ImageURL As String = dsImage.Tables(0).Rows(i - 1).Item("ImageURL")
Dim iImgID As Integer = dsImage.Tables(0).Rows(i - 1).Item("ImageId")
Dim physicalName As String = HttpContext.Current.Server.MapPath(ImageURL)
oUpload.DeleteFileFromServer(physicalName, iAdID, iImgID)
In this latter case, HttpContext.Current.Server.MapPath(ImageURL) has a value of Nothing.Is there a way to get the full path for this case?
View 1 Replies
Feb 12, 2011
For instance if I'm inside the Page_Load method and I want to get query string data I just do this:
public partial class Product_Detail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
[code].....
View 4 Replies
Jun 7, 2010
i have problem accessing HttpContext.Current.Application From global.asax its seems to be null every time i try to access it. How can i to this?
HttpContext.Current.Application.Lock();
HttpContext.Current.Application["Actions"] = "hello";
HttpContext.Current.Application.UnLock();
View 2 Replies
Dec 15, 2010
During Application_End() in Global.aspx, HttpContext.Current is null. I still want to be able to access cache - it's in memory, so want to see if I can reference it somehow to save bits to disk.
Question - is there a way to reference cache in memory somehow when HttpContext.Current is null?
Perhaps I could create a global static variable that would store pointer to cache that I could update on HTTP requests (pseudo: "static <pointer X>" = HttpRequest.Current) and retrieve a reference to cache through that pointer in Application_End()?
Is there a better way to access Cache in memory when there is no Http Request is made?
View 3 Replies
Oct 20, 2010
am writing a web service in vb.net/asp.net 2, that needs user's name. It works fine when the url request is "www.mysite.com" but if any one has logged-in using "mysite.com" without a "www" and goes to the page that calls my web service, The HttpContext.Current.User.Identity.Name gives null. How can I resolve this problem?
View 2 Replies
Jan 15, 2010
Where does httpcontext.current.server.mappath start?
I don't get it... it doesn't return a path.
My webservice is ran when I debug my application :S.
View 4 Replies
Mar 28, 2011
Last night I wrote up my first IHttpModule to do some request processing. I'm using a regular expression to inspect the raw url. The IHttpModule will be called on every request, so it seems reasonable to do some sort of caching of the regular expression object to prevent creation of it on every request.
Now my question... what is better: use the HttpContext.Current.Cache to store the instantiated object or to use a private static Regex in my module?I'm looking forward to the reasons why. Just to clarify: the regex will never change and thus always be the same thing.
View 3 Replies
Oct 13, 2010
I wanted to understand the behavior of HttpContext.Current.Application during the load balancing. I have read that session can be stored in disk hence can be retrieved from different servers. Is this true for HttpContext.Current.Application also. Does the keydata stored in one machine is accessible in other different machine too?
View 1 Replies
Mar 28, 2010
I reference the current page in a class with
Page page = HttpContext.Current.CurrentHandler as Page;
I know need to reference ScriptManager1. What the syntax ?
View 2 Replies
May 5, 2010
I am searching to find a way to read and write on session data but with out having the HttpContext.Current.Why I won to do that ?, because I wish to make some action with the user Session after the page have been close and unloaded. For example, a user load and see a page, then I create a thread to make some action and let user go. Inside this thread I like to read the session data, but in this case HttpContext.Current is not exist any more.
So is there a way to read Session Data knowing just the session id.I store my session inside an sql server, and I see them... its there on table ASPStateTempSessions . How can I read them "offline" and manipulate them ?
View 2 Replies