Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8189103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:09:38+00:00 2026-06-07T03:09:38+00:00

I have an Asp.net webservice. It has method M1. M1 creates a folder for

  • 0

I have an Asp.net webservice. It has method M1. M1 creates a folder for each session. When a session is expired, I delete that folder in global.asax using the following code.

void Session_End(object sender, EventArgs e)
    {
        try
        {
            System.IO.DirectoryInfo dirMyPacksFolder = new System.IO.DirectoryInfo(Utilities.getMyPacksFolder(Session));
            //dirMyPacksFolder.Parent.CreateSubdirectory("ended_" + Session.SessionID);
            if (dirMyPacksFolder.Exists)
            {
                dirMyPacksFolder.Delete(true);
            }
        }
        catch (Exception ex)
        {
            Utilities.logException("", ex);
        }
    }

When I open my webservice in browser and call M1, it operates correctly and the folder is deleted on timeout expiration time that I have set. But when I submit “Invoke” button of webservice for the second time (after session timeout and folder is deleted), its session starts (create folder) and ends (deletes folder) immediately before timeout that I have set.

Why this happens?

If I open a new window (new session) for each method call everything is OK. But I have problem when I click “Invoke” button for second time. It is something like caching problem for same sessions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:09:40+00:00Added an answer on June 7, 2026 at 3:09 am

    Have a look at this post, I believe your problem may be similar:

    • Client sends a cookie with a Session Id for an expired session
    • Server creates a new session, reusing the id sent by the client
    • If the request does not access session, the session is immediately abandoned.

    Does your WebMethod actually access Session state? If not, try adding an access to a dummy session variable.

    Update:

    These lines of code in Global.asax solve the problem:

     void Session_Start(object sender, EventArgs e)
     {
         Session["dummy"] = "dummy session for solving immediate session expire";
     }
    

    Update 2

    Personally I wouldn’t do the directory creation in Session_Start; instead I’d have a method called something like EnsureMyPacksFolder which the app is required to call before any attempt to access the folder. This would look something like the following, avoids the need for a “dummy” Session variable, and means the folder is only created if and when it is actually needed.

    Global.asax:

    void Session_Start(object sender, EventArgs e)
    {
         // No code needed in Session_Start
    }
    
    void Session_End(object sender, EventArgs e)
    {
        if (Session["MyPacksFolder"] != null)
        {
            // Folder has been created, delete it
            // ... add code to delete folder as above
        }
    }
    

    Somewhere else:

    public static void EnsureMyPacksFolder()
    {
        if (Session["MyPacksFolder"] == null)
        {
            // Add code to create MyPacksFolder that was previously in Session_Start
    
            Session["MyPacksFolder"] = true;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a legacy WSE3 ASP.Net webservice here that defines a method GetFileContent(string fileName)
I have simple asp.net webservice has login method and its deployed on IIS server
I have an ASP.NET (.asmx) Web Service project that has a method like: public
I have an ASP.NET WebService that returns an object of List public class Students
I have an ASP.NET WebService that supports standard WSDL based SOAP calls and a
I have an ASP.NET website that is contacting a webservice. Everything works fine connecting
I have a ASP.NET SOAP web service whose web method creates a PDF file,
I have a WCF 4 REST WebService within a folder in my ASP.Net MVC
I have a asp.net webservice running in windows server 2003, i want it read/write
I have ASP.NET page, it calls webservice via $.ajax and returns result in json

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.