I just want to delete the Directory
which is in the project folder
.
That folder having all web sharing authority and permission
.
The problem is arising when i am deleting the folder
.
Folder is deleted from the serverpath(Virtual Directory)
.
But my problem is that when i complete my task and click on any control it will redirect me to the Login page
with the return url
as there is a secure authentication
on the root directory is available
In the command window, type the DEL /F file name command and press Enter to force delete the file that is in use. Note: In the above command, the file name must be replaced by the name of the file along with its extension that you want to delete. For example del /f TestFile.
Application domain recycled when Sub-Directories are deleted, that's why your session will lost and you are redirected to the login page.
For more details, check this article from MSDN Blog and read Why does an application domain recycle? from here ASP.NET Case Study: Lost session variables and appdomain recycles
and also check this one Deleting ASP.NET 2.0 Application Sub-Directories Shuts Down the AppDomain
As noted in another answer, this is because the web app is restarted whenever you delete a folder inside the web app's directory structure (i.e. below the web app's root directory).
The only solution I found for this problem is to move the data directories (which you create/delete/modify) outside the web app's root directory / virtual directory.
Then we create a link (junction) in the file system so that the directory appears to be inside the virtual directory. This prevents ASP.NET from monitoring the data directory for delete operations.
Example:
C:\projectX\website
C:\projectX\data
C:\projectX\website\data
The link is created using the program Linkd.exe
(available in the windows resource kit), with the following command:
linkd c:\projectX\website\data c:\projectX\data
Now C:\projectX\website\data
is a link/junction which points to the real data directory. Inside your web app, you can continue working as if the data directory were a physical directory below the web app's root directory.
E.g. in your web site you can access the data folder using this code:
Server.MapPath("~/data")
And you can also used the windows file explorer and browse to C:\projectX\website\data. It appears just like a real directory.
As you can see, you can continue to use the linked data folder as if it were a normal folder inside the web app's directory. The only difference is that ASP.NET will not track the directory for delete operations and will therefore not restart the application. This means, you can now create/delete/modify folders and files inside the ~/data
directory as you wish, without having the web app restarted.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With