Send File then Response.Redirect the Another page but Session objects null

Thread is closed for posting
4 posts, 0 answers
  1. YAVUZ
    YAVUZ avatar
    18 posts
    Member since:
    Aug 2008

    Posted 28 Feb 2011 Link to this post

    Hi,

    I use RadProgressManager (2009.2.701.35) and RadUpload in my web page. I fill the blanks and send the file in page. Then I push the send to Approve button. This button save the some fields and filenames then Response.Redirect to root page. When response on the root page session objects values null. How to avoid this error ?
    in Aspx Page
    <td id="controlContainer" style="width: 430px">
                                   
                                        <telerik:RadProgressManager ID="Radprogressmanager1" runat="server" />
                                 
                                      
                                        <telerik:RadUpload
                                    ID="RadUpload1" runat="server" 
                                    Skin="Vista"
                                    MaxFileInputsCount="1"
                                    OverwriteExistingFiles="false" 
                                     ControlObjectsVisibility="None" Culture="Turkish (Turkey)" 
                                    ReadOnlyFileInputs="True" InputSize="46" 
        Width="300px" >
                                            <Localization Select="GÖZAT" />
                                        </telerik:RadUpload>
                                        <asp:Button ID="btnSendFile" runat="server" OnClick="btnSendFile_Click" 
                                            text="Gönder" />
                                  
                            </td>
    in Web.Config
    <?xml version="1.0"?>
        <configSections>
            <sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                <sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                    <section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                    <sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
                        <section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
                        <section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                        <section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
                        <section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup>
                </sectionGroup>
            </sectionGroup>
        </configSections>
      <appSettings>
        <add key="repositoryFilename" value="\\LBL\\EXPENSEPRINT.tff" />
        <add key="dataDirectory" value="\\data\\" />
      </appSettings>
        
        <connectionStrings>
            <remove name="LocalSqlServer"/>
            <add name="LocalSqlServer" connectionString="data source=.\SQLEXPRESS;Integrated Security=yes;AttachDBFilename=|DataDirectory|aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient"/>
        </connectionStrings>
      <location path="Telerik.RadUploadProgressHandler.aspx">
        <system.web>
          <authorization>
            <allow users="*"/>
          </authorization>
        </system.web>
      </location>
      
        <system.web>
            <httpRuntime maxRequestLength="819200" executionTimeout="3600"/>
            <globalization culture="en-GB" uiCulture="en-GB"/>
            <pages>
                <controls>
                    <add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                    <add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></controls>
            </pages>
            <!--
              Set compilation debug="true" to insert debugging
              symbols into the compiled page. Because this
              affects performance, set this value to true only
              during development.
        -->
            <sessionState timeout="1000"/>
            <authentication>
                <forms loginUrl="Default2.aspx" timeout="1000"/>
            </authentication>
            <identity impersonate="true"/>
            <compilation debug="true">
                <assemblies>
                    <add assembly="System.DirectoryServices, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                    <add assembly="System.Drawing.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                    <add assembly="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                    <add assembly="System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                    <add assembly="System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="System.Runtime.Remoting, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                    <add assembly="System.Management, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
                    <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                    <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                    <add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                    <add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
                    <add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                </assemblies>
            </compilation>
            <httpHandlers>
                <remove verb="*" path="*.asmx"/>
                <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
                <add path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.RadUploadProgressHandler, Telerik.Web.UI" validate="false"/>
      
          <add path="trace.axd" verb="*" type="System.Web.Handlers.TraceHandler" validate="True" />
          <add path="WebResource.axd" verb="GET" type="System.Web.Handlers.AssemblyResourceLoader" validate="True" />
            
          <add path="*.axd" verb="*" type="System.Web.HttpNotFoundHandler" validate="True" />
            </httpHandlers>
            <httpModules>
                <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI"/>
            </httpModules>
            <authorization>
                <deny users="?"/>
                <allow users="*"/>
            </authorization>
        
      
      
      
      
      </system.web>
      <system.web.extensions>
        <scripting>
          <scriptResourceHandler enableCompression="false" enableCaching="true" />
        </scripting>
      </system.web.extensions>
        <system.webServer>
            <validation validateIntegratedModeConfiguration="false"/>
            <modules>
                <remove name="ScriptModule"/><add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" preCondition="managedHandler"/>
        </modules>
            <handlers>
                <remove name="ScriptHandlerFactory"/>
                <remove name="ScriptHandlerFactoryAppServices"/>
                <remove name="ScriptResource"/><remove name="WebServiceHandlerFactory-Integrated"/>
                <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
                <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
          <add name="Telerik.RadUploadProgressHandler.ashx_*" path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" preCondition="integratedMode,runtimeVersionv2.0"/>
        </handlers>
        </system.webServer>
        <system.codedom>
            <compilers>
                <compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
                    <providerOption name="CompilerVersion" value="v3.5"/>
                    <providerOption name="WarnAsError" value="false"/></compiler>
                <compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
                    <providerOption name="CompilerVersion" value="v3.5"/>
                    <providerOption name="OptionInfer" value="true"/>
                    <providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom>
        <runtime>
            <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
                <dependentAssembly>
                    <assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
                    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly>
                <dependentAssembly>
                    <assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
                    <bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly></assemblyBinding></runtime></configuration>
  2. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 02 Mar 2011 Link to this post

    Hello,

    What do you store in the session? Could you please post your code-behind?

    Greetings,
    Helen
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. YAVUZ
    YAVUZ avatar
    18 posts
    Member since:
    Aug 2008

    Posted 02 Mar 2011 Link to this post



    protected void btnSendFile_Click(object sender, EventArgs e)
        {
            bool fCont = true;
            //string targetFolder = @"\\abttur02\BILDIRIMFOLDER";
            string targetFolder = Server.MapPath("~/BILDIRIMFOLDER");
      
            if (Directory.Exists(targetFolder + "\\" + Session["pNewGuid"] + "") == false) 
                Directory.CreateDirectory(targetFolder + "\\"+Session["pNewGuid"]+"");
      
              
              
            Session["targetFolder"] = targetFolder;
      
            if (RadUpload1.UploadedFiles.Count == 0)
            {
                fCont = false;
                ShowMessage("Lütfen upload edeceginiz dosyayi seçiniz !");
            }
            foreach (UploadedFile f in RadUpload1.UploadedFiles)
            {
                if ((f.GetName().IndexOf("_") != -1) || 
                    (f.GetName().IndexOf("I") != -1) ||
            (f.GetName().ToLower().IndexOf("i") != -1) || 
                    (f.GetName().ToLower().IndexOf("ü") != -1) ||
                    (f.GetName().ToLower().IndexOf("ö") != -1) ||
                    (f.GetName().ToLower().IndexOf("s") != -1) ||
                    (f.GetName().ToLower().IndexOf("ç") != -1) ||
                    (f.GetName().ToLower().IndexOf("g") != -1))
                {
                    fCont = false;
                    ShowMessage("Lütfen upload edeceginiz dosyanin isminde _ karakteri veya türkçe karakter bulunmasin !");
                }
            }
              
            if (fCont == true)
            {
                foreach (UploadedFile f in RadUpload1.UploadedFiles)
                {
                    if (File.Exists(targetFolder + "\\" + Session["pNewGuid"] + "\\" + f.GetName()) != true)
                    {
                        f.SaveAs(targetFolder + "\\" + Session["pNewGuid"] + "\\" + f.GetName(), false);
                        rdUploadedFiles.Items.Add(f.GetName().ToString());
                        Session["filename" + rdUploadedFiles.Items.Count] = f.GetName();
                          
                    }
                }
            }
      
            int fFileCounter = 0;
            DirectoryInfo di = new DirectoryInfo(targetFolder + "\\" + Session["pNewGuid"] + "");
            FileInfo[] rgFiles = di.GetFiles("*.*");
            foreach (FileInfo fi in rgFiles)
            {
                fFileCounter++;
            }
            if (fFileCounter == 5)
                btnSendFile.Enabled = false;
            if (fFileCounter >= 1)
                btnDeleteFile.Enabled = true;
              
              
        }

    protected void btnSendToApp_Click(object sender, EventArgs e)
        {
            bool fContinue = true;
            if (txtRotationUser.Text.Trim() != "")
            {
                ShowMessage("Yönlendirme bilgisi doluyken bu özellik kullanilamaz !");
                fContinue = false;
            }
      
            if (txtRefuseReason.Text.Trim() != "")
            {
                ShowMessage("Red sebebi doluyken bu özellik kullanilamaz !");
                fContinue = false;
            }
      
            DateTime dt = DateTime.Now;
            TimeSpan dCmpDate;
            dCmpDate = Convert.ToDateTime(dteMeetingDate.SelectedDate) - dt;
            if ((dCmpDate.Days + 1) < 33)
            {
                ShowMessage("Kongre tarihine 33 günden az bir süre kaldigindan bildirim girilemez !");
                fContinue = false;
            }          
            if (fContinue)
            {
                //1 onaya gönder
                if (SaveFiche(1))
                {
      
      
                    if (!Convert.ToBoolean(Session["redirected"]))
                        Response.Redirect("FicheBrws.aspx?id=0&ref=0");
                    else
                        Response.Redirect("ThanksForm.aspx");
                }
            }
        }
    Hi,
    Thank you for your reply. I will paste the code behind source.
  5. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 07 Mar 2011 Link to this post

    Hello YAVUZ,

    I'm afraid I couldn't follow your logic easy. Which Session object is null? I noticed you have several Session objects:

    - Session["pNewGuid"]
    - Session["targetFolder"]
    - Session["redirected"]

    Since the scenario is more complex - could you please isolate it in a simple runnable project and send it us?
    We will examine the files locally and try to find a solution.

    Regards,
    Helen
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top