Tracking Forums, Newsgroups, Maling Lists
Home Submit Tracker Forums
  Advanced Search
  HOME    TRACKER    ASP.NET


Advertisements:










Mock/fake The Session Object In .Net Web Forms?


Is there a way to mock/fake the session object in ASP.Net Web forms when creating unit tests? I am currenclty storing user details in a session variable which is accessed by my business logic. When testing my business logic, in isolation, the session is not available. This seems to indicate a bad design (though im not sure). Should the business logic layer be accessing session variables in the first place?

If so, then how would I go about swapping the user details with a fake object for testing?


View 4 Replies (Posted: Dec 30 09 at 17:44)

Sponsored Links:

Related Forum Messages For ASP.NET category:
Web Forms :: Session Ended - But Server Error/ Object Reference Not Set To An Instance Of Object?
In the VS2005 environment, when I test my session to make sure the page redirects to the main page (itself) if the session is null, it works.  There is no error.

The function I use for this is:

[code]....

However, when it is in the production environment in IIS 6.0, when the session has timed out, and I then do a postback by doing some slider control, I see the page reload but immediately thereafter, it throws a Server Error exception of : Object reference not set to an instance of object.

Looking at the stack trace, the event occured: 

AJAXEnabledWebApplication1._Default.Slider1_TextChanged(Object sender, EventArgs e)

however, why is it that the Slider1_TextChanged event fired even even after during page_load, the page was told to do a response.direct ?? shouldn't the entire page have gone through a full-page refresh life cycle ?  why did it continue on to attempt to raise the Slider1_TextChanged event?

Posted: Nov 15, 2010 10:08 PM

View 1 Replies!   View Related
Create A Copy Of An Object In Session To Update Without Updating Session?
I am confused about how to reference objects in session, how to update, and copy.

if I create
MyObject obj = new Object ();
then
Session["object"] = obj;
MyObject temp = (MyObject)Session["object"];

If i change something on temp, will the object in session be updated? do i need to follow changes with Session["object"] = temp?

Posted: Jul 20 10 at 14:49

View 2 Replies!   View Related
State Management :: How To Manage Session Data Outside The Session Object
I want to be able to persist data across a session but do this outside of the built-in session state object.  Why is a long story that I will not go into here.  I just need to know where I can put data other than in the session object that will persist across the specific session.

Posted: Oct 07, 2010 04:16 AM

View 3 Replies!   View Related
Session - Object Reference Not Set To An Instance Of An Object?
I have this problem when trying to read a session in another asp.net page.

Object reference not set to an instance of an object.

If Session("cne").Equals("") Then Response.Redirect("Default.aspx")End If

I'm setting the session in the Default page with this code :

Session("cne") = cne.Text

Posted: Jun 19 10 at 23:52

View 1 Replies!   View Related
C# - How To Fake HttpContext For Unit Tests
I need to fake HttpContext.Current.Application table to access it from my unit tests.I need to store my data somewhere. I thought that I can just pass instance of NameValueCollectionBase but as I descover this base type has no indexer so it's too complicated to use. So what about faking this part of HttpContext? Is it possible? How can I make it? Will be NUnit.

Posted: Aug 15 10 at 16:16

View 2 Replies!   View Related
Configuration :: Displaying Fake Url In Address Bar?
I am working on an ERP Application as a software Developer.

For security reasons, I want to display same url on web page's addressbar.

i.e. If user clicks on any internal link of  application, URL shown in addressbar should not be changed.

It should be static like www.example.com for every page of the application.

Posted: Aug 04, 2010 11:32 AM

View 3 Replies!   View Related
How To Create A Fake URL When Displaying A Page
I remember doing something like this in a CMS i used few years ago.. not sure what it was called or considered. Maybe its url aliasing, but not sure but here is what im trying to accomplish, based on the url / post data passed that a physical location is returned to our application.

So the url will always be unique to the request, but it will never be a valid url that will display anything..

The concept here is that we have the following structure.. We have the C# code that will initiate a HTTP request of a file (test.dat) IIS7 already has a handler setup for that file, when it receives that request, it does a DB lookup and returns the physically location on the server for our application to use.

So is there a way to send a fake http request to our server so that the custom handler is triggered Im not sure if i explained this correctly, but hopefully i did..

The application we are working on is a custom video playback app, IIS has been setup with the handler for the .dat file we are working with.. the video playback will need the entire physical path in order to play.. as far as the site is concerned, it just needs to initiate the request..

[URL] would be an exaple of the request.. but somehow passing along in the background video specific information in order to return the correct path.

Posted: Mar 07, 2011 09:25 PM

View 5 Replies!   View Related
Web Forms :: Using Themes, MasterPages On A Multi Portal Web Project, "fake App_Themes"
I would like to use the theme system of asp.net so the styles, images and masterpages can be set in a subfolder like so "/Sites/Site01/Themes/ThemeName/MasterPage.master".

All the styles CSS file will be inside of the custome folder including images. How do i make my webproject to read the good location of each of my websites? And how can i make the images work "path" when inserted in the master page?

Posted: Aug 20, 2009 02:09 PM

View 6 Replies!   View Related
Web Forms :: Invoke Close Session Object?
On my web page, I've a shared object with initiate (open session) on the load event.

I would like to close this object when the page is close and invoke a close session method.

how do I use the event to do this?

Posted: Mar 26, 2010 04:08 PM

View 2 Replies!   View Related
MVC :: How To Mock Smtp
in one of my controllers, i have an action sending mail. I want to do a unit test on it.

How do i mock the smtp?

Posted: May 24, 2010 05:35 AM

View 7 Replies!   View Related
Web Forms :: Storing SiteMapNode Object In Session Not Working?
I am using Session state in my ASP.NET application. The development is done using InProc session state as the option, but now the application is deployed on a Web Farm(Cluster) environment. As a result, InProc session state is not working.

I have changed the session state mode to SQL server so the session state will work in Web Farm environment. But now i am getting a different error because of some of the objects which i have already used with Session.

Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.

I understand that every object that is stored in Session needs to be serialized. But there are some objects which are not serializble in DOTNET.

Unfortunately i am using one of them, SiteMapNode. I am storing this object in session to re-create the breadcrumb based on the navigation the user has performed. I have to do this because there are mulitiple paths leading to single page in my application.

I have tried to do serialization of this object using XML serializer object, but its throwing an exception:

"System.Web.SiteMapNode cannot be serialized because it does not have a parameterless constructor."

I can't change the code of storing the SiteMapNode in session as it is very complex and written by someone else. I have to store this object in session or some other state form so that i can continue using the same code.

Posted: Jan 21, 2010 03:58 AM

View 3 Replies!   View Related
Web Forms :: Creating Application Level Session Object?
creating session object to use across my web application.

I'm working on an application that requires a login control upon which we would need to set around 10 different session variables (related to the user). These values are required/ used many times across the web application so it would be really handy to create a class/ object which can be accessed in all pages with doing multiple lookups into the user table on DB. Also, I would like to avoid any conflicts with multiple developers using same session variable names and thereby causing issues down the road.

I know this is not a new kind of request and must have been created and used by many of the developers.

Posted: Mar 24, 2011 02:33 AM

View 4 Replies!   View Related
Web Forms :: Preserve The Session Object While Redirecting Between Domains?
In my app. I redirect user from one domain to another and I need to preserve the session object while redirecting between domains.

I need to be able to read session key/value that is created under different domain, for example -

While in domain A.com:

create session variable - session("myASPString") = "Test string"

redirecting to domain B.com

While in domain B.com:

dim k as string = session("myASPString")

right now k = Nothing...

How can I preserve the session object between different domains ?

Posted: Oct 16, 2010 06:35 AM

View 1 Replies!   View Related
Fake Image Using .aspx Url To Track Email Views In Outlook, Doesn't Work
I have this in my HTML email to track if someone views the email in say Outlook.

<img src="http://www.example.com/track.ashx?user=3434" />

but this doesn't seem to work.Should I change my headers in the .ashx to server image headers? Can this work using this method?

I emailed myself with an email, other images displayed properly. There was no log in the database for the handler (the handler logs all requests to the db). Calling the URL to the file in the browser logs to the db, so its working.

Posted: Apr 15 10 at 20:26

View 2 Replies!   View Related
MVC :: Mock MemberShip.GetUser?
I need to mock MemberShip.GetUser() method to test my controller but somehow i am not able to do it.

Posted: Oct 21, 2009 11:39 AM

View 2 Replies!   View Related
Error "Object Reference Not Set To An Instance Of An Object" With Using Session
I am getting thid error Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for 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:  

Line 18: 
Line 19: <%&nbsp;
Line&nbsp;20:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;string&nbsp;thedate&nbsp;=&nbsp;Session["indate"].ToString();////;;;;????
Line&nbsp;21:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Response.Write("Starting&nbsp;SAS");
Line&nbsp;22:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;try &nbsp; &nbsp;
Source&nbsp;File:&nbsp;c:Documents&nbsp;and&nbsp;SettingsAdministratorMy&nbsp;DocumentsVisual&nbsp;Studio&nbsp;2008WebSitesWebSite1SASrun.aspx&nbsp;&nbsp; &nbsp;
upload.aspx
<%@&nbsp;Page&nbsp;language="c#"Debug&nbsp;=true&nbsp;Codebehind="upload.aspx.cs"&nbsp;AutoEventWireup="false"&nbsp;
Inherits="Stardeveloper.UploadAccess.UploadForm"&nbsp;%>      
<script  runat="server">  
void Button2_Click(object sender, EventArgs e)    
{
Session["indate"] = Request["txtDate"];
Response.Redirect("SASrun.aspx");
}  
</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >  
<html>
<head>
</head>
<body>
<body style="background:#80B584">
<form runat=server>
<a href="default.aspx"><b>Main Page</b></a> · Upload Files 
<div id="message" runat="server" />
<table align="left" border="0" cellspacing="0" cellpadding="3">
<p style="font-family:arial;color:White;font-size:20px;">Upload new files.</p>
<tr><td><b>MTMDetailed:</b></td><td><input type="file" class="stdInput" name="uploaded_file1"></td></tr>
<tr><td><b>File TRI_FP:</b></td><td><input type="file" class="stdInput" name="uploaded_file2"></td></tr>
<tr><td><b>indate     :</b></td><td><input type="text"id="txtDate" name="inputdate"/></td></tr>
<tr><td align="right"><input type="submit" value="Submit"></td></tr>
<asp:Button id="Button2" runat="server" Text="Submit" onClick="Button2_Click" />
</table>    
</form>  
</body>
</html>  

This is part of the code where error is coming from................

Posted: Dec 17 10

View 1 Replies!   View Related
Mock 3.5 To Unit Test Web Controls?
I want to mock ASP.NET 3.5 behavior in order to unit test my WebControls: I want to test how they perform with mock data with existing system of events. Basically I want to test generated result HTML based on input mock data. How to do it? I looked into NMock, but it doesn't suit my needs for 2 reasons:

It just runs ASP.NET server in separate process in order to get resulting HTML; My WebControls output HTML as a text on render, so there are elements which do not correspond to any ASP.NET control (except LiteralControl in some cases). Also, I have huge legacy system, so rewriting everything for MVC won't work for me (too much job), I need to write unit tests to existing controls.

Posted: Feb 4 10 at 0:54

View 1 Replies!   View Related
Unit Testing - How To Mock A Model In MVC
I've made a custom model, and I want to mock it. I'm fairly new to MVC, and very new to unit testing. Most approaches I've seen create an interface for the class and then make a mock that implements the same interface. However I can't seem to get this to work when actually passing the interface into the View. Cue "simplified" example:

[code]...

Upon a HttpPost I get a "Cannot create an instance of an interface" exception. I seems that I can't have my cake (passing a model) and eat it (pass mock for unit testing). Maybe there's a better approach to unit testing models bound to views?

Posted: Nov 11 10 at 17:17

View 3 Replies!   View Related
MVC :: How To Mock IPrincipal Inside Controller
I need to mock this controller action:

[Code]....

I know that this works because I've already used it via a View in a browser. But when I try to mock it in a test using NUnit and Rhino Mocks, it always chokes on the Page.Identity.name in the GetUserId() method.
I thought I had it but I'm obviously missing something.

Here's my CreateController method in my TestFixture:

[Code]....

Posted: Sep 14, 2009 11:43 PM

View 6 Replies!   View Related
Creating A Mock URL Referrer In MVC For Unit Testing?
I'm currently testing my application and am stuck on trying to figure out how to create a custom fake URL referrer. I've tried to hard code it, but am getting an error that it is read-only. Here is what I've tried so far:

fakeController.HttpContext.Request.UrlReferrer.AbsolutePath = "http://www.yahoo.com";
as well as,
fakeController.Request.UrlReferrer = "http://www.yahoo.com";

I've searched the web for some ideas on how to create a fake/mock URL referrer for my fake controller, but have had no luck.

Note: I'm using Visual Studios built-in unit testing facilities.

UPDATE:

I would be more than willing to use any other unit testing system outside of Visual Studio, unfortunately here at my work we are only allowed to use Visual Studio's built-in system, so I gotta work with what I've got.

Posted: Feb 10 10 at 17:57

View 3 Replies!   View Related
Unit Testing / Mocking HttpContext Without Using Any Mock Framework
Since I'm having problem with unit testing RenderPartialViewToString() with Moq framework [URL] I'm thinking about getting my controller directly, without using Moq for these particular test, however, how do I mocks (or set) the HttpContext for my test without using any Moq framework?

I need to able to do something similar to this, without Moq of course:

var mockHttpContext = new Mock<ControllerContext>();
mockHttpContext.SetupGet(p => p.HttpContext.User.Identity.Name).Returns("n1\test");
mockHttpContext.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);

Posted: Sep 7 10 at 18:54

View 2 Replies!   View Related
Architecture :: Unit Testing Delegates With Mock Framework?
I'm using the mock framework to unit test some methods. I came across some methods that use delegates. I did not find a way to setup these delegates to return the objects that I want. The mock framework does not support it as far as I know. Is this supported in other mock frameworks like nMock?

Posted: Apr 03, 2011 03:11 AM

View 3 Replies!   View Related
Mock Server.HtmlEncode - Returns Null Reference?
I'm trying to mock Server.HtmlEncode(), but I keep having a null reference exception.I'm pretty new to the Moq framework, here is my code:

var context = new Mock<HttpContextBase>();
var request = new Mock<HttpRequestBase>();
var response = new Mock<HttpResponseBase>();
var session = new Mock<HttpSessionStateBase>();
var server = new Mock<HttpServerUtilityBase>();
server.Setup(svr => svr.HtmlEncode(It.IsAny<string>())).Returns((string s) => s);
context.Setup(ctx => ctx.Request).Returns(request.Object);
context.Setup(ctx => ctx.Response).Returns(response.Object);
context.Setup(ctx => ctx.Session).Returns(session.Object);
context.Setup(ctx => ctx.Server).Returns(server.Object);

I've also tried the following:

context.Setup(ctx => ctx.Server.HtmlEncode(It.IsAny<string>())).Returns((string s) => s);

I've found a solution but it seems an outdated solution as expect is replaced with setup.

Posted: Nov 16 10 at 10:09

View 2 Replies!   View Related
Forms Data Controls :: Binding Formview To Strongly Typed DataTable In Session Object?
Okay, here's something that I could easily do the hard way and manually wire up each form element and save it to a datatable in memory, but there has to be a more efficient way to do it. 

Here's what I have:

1. A strongly typed datatable and tableadapter in a XSD name Orders

2. A formview control which currently is connected to an ODS connected to the Orders tableadapter, this makes it easy to wire up the databindings for each form field in design view

I would like to:

- bind the the formview to an instance of the strongly typed datatable, and then save the dt to a session object without interacting with the actual database

- load forms on subsequent pages from the dt in session

- ultimately save the dt info to an actual database table on the third page

I've read some solutions where a custom class is created, but to me this seems like almost as much work as wiring up the form field to the table columns manually in code.

Posted: Sep 29, 2010 04:05 PM

View 1 Replies!   View Related
C# - Mock MVC Site, An Outline For Coders To See Functionality And To Start Coding?
I have to setup an MVC project to house all the HTML documents. This would be like a hierarchical structure using routing. The pages don't have to function, just act as placeholders. It's really just for the group to see all the HTML Pages to get an Idea of functionality. Then we would back fill groups of pages with the functionality by creating the controllers, model etc. How would this be best accomplished? Are there mock frameworks that could accomplish this? So it would be a project just having views, with a control ler that allows navigation between pages, simple to show mostly static HTML pages. The idea is simply for the group to see all the functionality, and to put together a structure to start coding. If possible we would like to see the correct URL based on the route table. What would be a quick solution for this while we work on the back end Object/Domain model?

Posted: Oct 20 10 at 16:08

View 1 Replies!   View Related
Using The Session Object In VB.Net
What namespace do I need in order to use the Session Object in my VB.Net code-behind?

Posted: Feb 17th, 2011, 05:15 PM

View 7 Replies!   View Related
MVC :: Controller Unit Test Using Authorization And Mock Http Context Does Not Work?
i'm testing a simple "Person" controller, with default "Index" action with [Authorize] attribute, using Moq framework. The problem is, even if i set request.IsAuthenticated to false or true, the view rendered is always the same. Here is it the action:

[Code]....

Here is my test method:

[Code]....

Posted: Oct 22, 2009 07:09 PM

View 4 Replies!   View Related
MVC :: Unit Test The Controller Actions By Injecting A Mock Repository For The Action Filter To Use?
I have created a custom action filter (attribute) that hits a database. How can I unit test the controller actions by injecting a mock repository for the action filter to use?

Posted: Jul 16, 2009 07:12 AM

View 7 Replies!   View Related
Cookies And The Session State Object?
my main concern is using Session. I've always been under the impression that if you use the following statements (not that I would):

Session["newVar1"] = "a new session variable";
Session["newVar2"] = "a new session variable";
Session["newVar3"] = aLargeVariableThatHoldsLotsOfData;

You would be creating 3 new session cookies that hold the particular value. But I think my asp book is indicating that you would actually create 3 new variables in your session state object and ASP would only pass a unique Session ID (as a cookie?) in the response, and would get this ID upon the next request and associate that ID with your Session State Object (that IIS has stored in memory..?):

[code]....

That doesn't seem ideal for a website with lots of traffic. A server that is storing and maintaining thousands and thousands of instances of session state per website seems like way too much overload.
I'm trying to see what's going on on my own, but I'm having trouble.. I can't find my site's cookies anywhere on my machine (IE/windows xp). I've checked C:Documents and Settings icholasrCookies and C:Documents and Settings icholasrLocal SettingsTemporary Internet Files which, according to this yahoo answer, IE cookies are stored as well. I'm using ticket authentication in my app which stores a auth cookie on the client, so a cookie from my site has to be somewhere..

Posted: Mar 29 at 18:38

View 1 Replies!   View Related
How To Save An Object To Session For Reuse
I'm new to asp.net 3.5 programming with VB.  I'm learning from murach's book. In one of the exercises it says to creat a customer tha has a first name, last name, and email address which I had no problem in doing.

Then it says to add an event handler of the Load event tha shoul check of the Customer object is session state and then display the information in the text boxes.  I can't seem to figure out how this is done

Posted: Jan 03, 2009 03:46 PM

View 4 Replies!   View Related
Cache Object Based On Session?
Global objects can be cached at application level. Static pages also cab cached(in fact it is global object).

My queston is: suppose I have a object class1 which is instanced by ID from database, suppose its constructor is class1(int ID). For one session, maybe different pages need same object class1(100), I share the ID=100 in session for user, but I dont want to load class1(100) everytime in different. how to cache this class1(100) based on session?

Different session maybe used for different instances  and don't want to put the instance in session becuase it is a big object.

Posted: Nov 20, 2008 02:18 AM

View 1 Replies!   View Related
MVC :: Clear Session Object In The View?
have been a great resource for me since i am new to MVC and trying to learn and figure out few things.My chain of thoughts still might be asp.net, so here is another question.I have a session object in my controller action which i use to populate my view , i need to clear the session object everytime i navigate out of the page (more like a session kill in page unload event). I really appreciate any ideas and inputs on how and where to clear the session object

Posted: Mar 05, 2010 03:16 PM

View 8 Replies!   View Related
C# - Session Object Is Null After Update?
I'm populating an object model with a linq query. The model looks like this:

MyModel{
DateTime AppointDate {get; set;}
int TotalAppoints {get; set;}
int AppointDuration {get; set;}
}

The linq-to-sql query looks like that:

public static GetAppointsFromDB(params){
var MyQuery = from....where...
select new MyModel{
AppointDate = ...,
TotalAppoints = ...,
AppointDuration =...};
return MyQuery as MyModel;}

In the master page, I'm looking to load the result of this query in the session like this:

if (Session["Appoints"] == null) {Session["Appoints"] = GetAppointsFromDB(...);}

When I run with the code, the session is always null. I added this line a second time, just right after, and the query runs again. When I'm looking to use the session at some other point in the code, it is null too there too. The query works because when I put a breakpoint on the return statement, I see the object properly filled.

Posted: Mar 27 at 16:25

View 3 Replies!   View Related
Session Object Design Pattern?
I'm looking to build an ajax page; it's a reporting page. By default, load today's report. On the page there's a calendar control and when the user clicks on a date, reload the gridview with the corresponding data. Is it considered good practice to do the following:

1) on the first page load, query the data for the page

2) put the query result in the session object and display it in a gridview

3) if the user requests new data, get new data from the query with different parameters

4) put the result of the second query in the session object and display it

5) if the user then requests the data from the first query, get it from the session object

6) do the sorting and paging with the data held in the session.

Note: the data of each query will contain about 300-500 rows and about 15 columns. I'd like to do all this with ajax calls. What are some suggestions and pitfalls to avoid.

Posted: Jan 28 at 2:01

View 4 Replies!   View Related
Storing Connection Object In Session Variable?
I have some webpages in my project, each web page contains same connection object more than one time .

I want to store a single connection object in a session variable and use it .

Is it possible and efficient to do like this ?

Posted: Apr 29 09

View 8 Replies!   View Related
How To Save Large Object In Session For Many Users
I ran into a situation where there is not memory for sessions.

In my application, I have an object whose size is very big. I have to make this object unique to each user. I am saving it in session.

If many people are accessing it, I am getting error saying 'Out of memory'.

I am thinking of 'Campressing' and saving the object in session.

Posted: Aug 29, 2008 06:39 AM

View 2 Replies!   View Related
C# - Object Losing Reference When Assigning It To Session?
I am facing a very strange issue. I get an error Object Reference Not set to instance of object on the server while the code runs fine on my dev machine. The strange part is the line number where the code is throwing error (as appears in the Stack trace)

DemoUser demoUser = new DemoUser();
if (!Request.QueryString.AllKeys.Contains("name"))
{
playerName = usr.NinjaName;
demoUser.Email = usr.UserEmail;
demoUser.UserPicture = usr.UserPicture;
}
else
{
playerName = Request.QueryString["name"];
demoUser.Email = String.Empty;
demoUser.UserPicture = "http://graph.facebook.com/1/picture";
}
demoUser.EntryDateTime = DateTime.Now;
demoUser.Name = playerName;
Session["DemoUser"] = demoUser;
imgPlayer.ImageUrl = demoUser.UserPicture; // This is throwing error.

If that line is throwing error then the demoUser object is getting lost when I assign it to Session. Is that right?

Posted: Oct 14 10 at 13:56

View 2 Replies!   View Related
How To Read Back An Object Stored In A Session
First of all, here comes the load part.

Structure MainStruct
Dim Ans1 As String
Dim Ans2 As String
End Structure [code]....

The question is how can i read back the contents of the list, stored in the Session?

I mean something like...Build = Session("MyData")

Posted: Jun 2 10 at 13:36

View 2 Replies!   View Related
Session Variable Object Gets Deleted On Postback?
I have made something like the following code:

protected void Page_Load(object sender, EventArgs e)
{
Label1.Text = Session["loginid"].ToString();
}
protected void delete_click(object sender, EventArgs e)
{
delete("mail1",Session["loginid"]);
}
private int delete(string mailid, string user)
{
System.IO.Directory.Delete(Server.MapPath(@"~files" + user + @"" + mailid), true);
}

When i press the delete button, everything works fine and the folder gets deleted. but after that when page postbacks again then a NullRefrenceException is raised at Label1.Text = Session["loginid"].ToString(); why is it happening...?? When I am not using this Directory.Delete() method everything is working fine and session variables are not set to null. When I traced my application I found that After Directory.Delete() method Session variables were intact and I was able to use those session variables in the processing after Directory.Delete(). But as soon as the page postbacks all session variables are set to null. And this problem doesn't appear when i m not using this delete() method. The folder I m deleting is in my project's folder. I m running this website using Visual Studio.

Posted: Feb 20 10 at 20:39

View 6 Replies!   View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved