.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Session Expires on File Delete

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :ASP.Net
Dear All, I am trying to delete Files and Directory through ASP.NET3.5 (C#)web application. But as soon as Directory\File is deleted It  automatically redirects me to Login Page. It means I am lossing my session on deleting File/Directory. Plz help me out.

View Complete Post

More Related Resource Links

Programmatically delete a .webpart file from wpcatalogs folder from an IIS website


We are using a third party wsp in our solution which directly adds the web parts into the web application store rather than the web part gallery(References to them are present in IIS site's wpcatalog directory). We want to remove these web part files so that the users will not be able to add these web parts to pages directly. Or any other modification so that users will not be able to add these directly. Is there a way we can do this programmatically?

How to delete an image file assigned to a PictureBox xontrol ?

In a Windows form application, some image files are assigned to PictureBox controls. I am trying to delete those image files. The first approach [1] with "Image.FromFile" gives an error message of "Another process is using this image file", although "Image.Dispose()" is executed. The second approach [2] using "Image.FromStream" results (X) images for PictureBoxes and Buttons, if "fs.Close()" is inclided. Without "fs.Close()", it gives the same error message of "Another process is using...". How can I display images properly and delete those images files ? Thanks [1] pictureBoxSelected.Image = Image.FromFile(@actualImage); . . . pictureBoxSelected.Image.Dispose(); pictureBoxSelected.Image = Image.FromFile(@tempImage);                                                if (System.IO.File.Exists(actualImage) == true) {     System.IO.File.Delete(actualImage); } [2] FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read); pictureBox.Image = System.Drawing.Image.FromStream(fs); fs.Close();

how to check one time java script file download not every session

how to check one time java script file download not every session

i make a web site using frame but session is expire Error message is my Config file is attache

i make a web site using frame  but session is expire message is Object reference not set to an instance of an object Description: HTTP 500. Error processing request. Stack Trace: System.NullReferenceException: Object reference not set to an instance of an object at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00000] in <filename unknown>:0 at System.Web.UI.Control.LoadRecursive () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.ProcessLoad () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.ProcessPostData () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.InternalProcessRequest () [0x00000] in <filename unknown>:0 at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] in <filename unknown>:0 My Web Config file is<configuration>    <!-- store the database connection info here -->     <appSettings>        <add key="sBook_StoreDBConnectionString" value="Provider=Microsoft.Jet.OLEDB.4.0;User ID=Admin;Data Source=C:\Program Files\CodeCharge\Examples\BookStore\BookStore_MSAccess.mdb;Persist Security Info=False" />            </appSettings>  <system.web>  <httpRuntime executionTimeout=&quo

How to delete a file which was accessed by other process ?

Does Windows have a "unlock object" method in order to delete a file which is being used by another process ? Thanks

Log file WSS_AdminService.log - can i delete it?

Hi, I've noticed that the size of a file WSS_AdminService.log every user profile setting eg. in C:\Documents and Settings\Default User\Local Settings\Temp is about 2GB currently. I understand that this file is updated by wssadmin.exe (the Windows SharePoint Services Administration service). questions: 1. we have many users who are no longer using the account to login to the server, can i delete teh file then? 2. is there a way that i can allow only a single file WSS_AdminService.log in a specific user account to be access by wssadmin.exe? in this case we can save more HDD space. because, if we have more than 50 users account, then 50 * 2GB and it's already 100GB. instead of 100GB, can we just make it 2GB and this file is share by all the sharepoint users? thanks. Sam. Does anyone have any insight into how I might alter what is logged or how often, or even just to persuade it to 'housekeep' better, as the file continues to grow (reaching 750MB on the first server I noticed this on)? As far as I can see it is not related to the Diagnostic logging settings in Central Administration > Operations. Renaming the file to append a date on a regular basis is my current solution - a new copy is then created by WSS Admin on its next log cycle.

delete a csv file created via StreamWriter?

I don't know if this is the correct forum.. but, is there a way I can automatically delete the following .csv file that was created via streamwriter (after it is viewed by an individual)?CODE (I would like to automatically delete the_filename.csv)://///////////////////////////////////////////////////////////////////////////////////////////////            string filename = "~/downloadfiles/data_complex987654321_filename.csv";             StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(filename));             StringBuilder sb = new StringBuilder();            string filename = "~/the_filename.csv";            StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(filename));            StringBuilder sb = new StringBuilder();

can not delete data file after emptying the file

hi, i have two data file groups. data and data_new. i moved all objects from file group data to data_new. i verified not a single object is there in data file group. i want to remove all files in file group data and and evantually filegroup as well. i am trying to delete the file present in this file group. but it is throwing error cant be deleted because file is not empty .any one plz suggest.

delete file from server

hello champs...i want to delete the folders present in server...but when writing  System.IO.File.Delete(Server.MapPath("~/uploads/loading.zip"))or directory.delete(path,true)it is giving error of permission denied...again if i manually change the permission of that folder for user type: users to modify,read,write full control then end user can delete the folder. how to solve it...pro grammatically

How can i delete the file uploaded in my web page?

 Hi Experts. I am writing a simple web page that  users can upload an image file. After the file is uploaded, Users can fill up  other question in the web page. then users click the submit button to register them and the file is uploaded previously is move to special folder and is saved there. Know i want to delete the uploaded file if the user upload the file but dont click the submit button and close the web page. because i dont need the file uploaded until the user is not registered. I use Session_End event but i dont know why it dont work. With Regards. Mojtaba

Can't delete database-file

HelloThis has been driving me crazy all day and I've had to shutdown the website so I'm pretty stressed right now.I'm trying to delete ASPNETDB.MDF on a server but I keep getting the error "Cannot delete ASPNETDB: It is being used by another person or program". I've shut down both the website and the SQL Server service but the problem remains.I've also tried detaching it using 'sp_detach_db' but get:"CREATE DATABASE permission denied in database 'master'. An attempt to attach an auto-named database for file ASPNETDB.MDF failed. A database with the same name exists, or specified file cannot be opened".The server is running Windows Server 2003 and Microsoft SQL Server 2005 Express.Any suggestions?Thanks.

Session Expires


i have web application it is working fine if i m not publishing and putting it into server it is working fine but if i publish that application and den put on server the session is being expired on each post back means if i click on any button my session expires it is only happening when i publish the application any body have idea how to solve this issue?? 

Session State in ASHX file


Hi People,

I have been trying unsuccessfully to retrieve a Session varaible from within an ASHX file that i'm using to build an XML file.

What I am trying to achieve is quite simple really.

My ASHX file is used to dynamically build an XML file so that I can then bind it to a TreeView control later on. However the dynamic part isn't quite working because the ID that I need from the session seems to not be passed into the ASHX file.

I have tried using the following methods to do this:

1) Include interfaces IRequiresSessionState and IReadOnlySessionState

2) Tried accessing the value like this: Session["ID"] or context.Session["ID"] or HttpContext.Current.Session["ID"]

I am setting the Session variable in the MasterPage's code behind.

Can anyone help?



Delete file Asyncronously that is uploaded by AsyncUploader



Suppose after Uploading file,i want to delete a particular file ,for that i have added a link, that calls a Web Service method to delete file stored in DataBase. That link is added throug JavaScript in OnClientUploadComplete JavaScript function. And this Delete link calls another JavaScript function that in turn calls Web Service method. But that delete link should contain some specified arguments against which file has to be deleted. I am confused how to pass that argument to dynamically created Link.

Please help

Delete Image file from file system


Hi guys,

I have a web site that you can upload images, the image path is saved in the ImgPath field in the data database and retrieves the image and displays it in the grid view. I want to be able to delete the image from a folder within my project when I delete the record. I'm trying to delete it from the Detailsview_ItemDeleting event.

Thanks for you help .

how to do checkin,checkout,undocheckout,delete operations for sharepoint 2007 document library file


i hope your understood my problem...

please suuggest me with your coading skills.....

thanks & regards



Redirecting to home page when session expires (without )


Hello guys, my web app doesn't use authorization in web.config, but i want to detect when a session has expired and redirect to the home page.

I have searched and found solutions that rely on the web app using authorization. Other solutions have implemented a user control to drop in every page.

Obviosly i don't want to manually check for null on every session variable on every event of the web app, so i want the app to do it automatically.

<sessionState timeout="120"></sessionState>
<authentication mode="Forms">
       <forms name="myappCookie" loginUrl="~/index.aspx" timeout="120"/>

doesn't work for me since i don't have allow or deny settings, since my app doesn't need authentication.

What are my options?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend