Click here to Skip to main content
15,916,949 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

In my Application I am opening the Document file and Converting that file to a HTML file. Its working fine but the values in the Session is lost when this action is performed can u please help me to solve this issue. I have not given any Response. Redirect method. I am just binding the Grid when the action is action is performed successfully. Here is my code.

C#
public void Upload()
   {
       object missingType = Type.Missing;
       object readOnly = true;
       object isVisible = false;
       object documentFormat = 8;
       object htmlFilePath = Server.MapPath("~/HelpFolder/HTML Files/") + hdFileName.Value + ".htm";
       //string directoryPath = Server.MapPath("~/HelpFolder/HTML Files/") + hdFileName.Value + "_files";
       ////Upload the word document and save to Temp folder
       object fileName = Server.MapPath("~/HelpFolder/Doc Files/")+hdFileName.Value+ ".Docx";
       //Open the word document in background
       Microsoft.Office.Interop.Word.ApplicationClass applicationclass = new Microsoft.Office.Interop.Word.ApplicationClass();
       applicationclass.Documents.Open(ref fileName,
                                       ref readOnly,
                                       ref missingType, ref missingType, ref missingType,
                                       ref missingType, ref missingType, ref missingType,
                                       ref missingType, ref missingType, ref isVisible,
                                       ref missingType, ref missingType, ref missingType,
                                       ref missingType, ref missingType);
       applicationclass.Visible = false;
       Microsoft.Office.Interop.Word.Document document = applicationclass.ActiveDocument;
       //Save the word document as HTML file
       document.SaveAs(ref htmlFilePath, ref documentFormat, ref missingType,
                       ref missingType, ref missingType, ref missingType,
                       ref missingType, ref missingType, ref missingType,
                       ref missingType, ref missingType, ref missingType,
                       ref missingType, ref missingType, ref missingType,
                       ref missingType);
       //Close the word document
       //document.Close(ref missingType, ref missingType, ref missingType);
       ((Microsoft.Office.Interop.Word._Document)document).Close(ref missingType, ref missingType, ref missingType);
       ((Microsoft.Office.Interop.Word._Application)applicationclass).Quit(ref missingType, ref missingType, ref missingType);

   }


Thanks
Posted
Comments
I can't see any Session values here in code.
Member 7946563 19-Dec-13 5:39am    
We are Assigning the session values in the login page this a separate Application which uses some session values like userid etc
How do you come to this app after Login?
Member 7946563 20-Dec-13 1:15am    
Ya I will come to this app after loging in to the webpage. In that login page I am setting nearly 8 session values. After running this code all the session values gets cleared.
Can't you debug and see the values on each line? You will get the idea where exactly session values are getting lost.

1 solution

Use timeout in web.config, can also use timespan--20 minutes is default, also The timeout attribute cannot be set to a value that is greater than 525,601 minutes (1 year) for the in-process and state-server modes.

<sessionstate>
    mode="[Off|InProc|StateServer|SQLServer|Custom]"
    timeout="number of minutes"............

   ....../></sessionstate>


msdn
Troubleshooting Expired ASP.NET Session State and Your Options
 
Share this answer
 
Comments
Member 7946563 20-Dec-13 1:15am    
I tried this but its not working
Member 7946563 31-Jan-14 7:06am    
Hi,

I have solved this issue the problem is I have used the delete directory option in my code so that code clears the Session values.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900