Working with Request.Files and Changing from POST to GET without reloading page?

Thread is closed for posting
4 posts, 0 answers
  1. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 04 Nov 2011 Link to this post

    Hi Telerik,

    I am trying to figure out if I have something wrong with my architecture, or if I am just in need of a quick fix.

    I have the following on my page:

    <csw:UploadDashboardRadWindow ID="UploadDashboardWindow" Runat="Server">
        <ContentTemplate>
            <div ID="UploadDashboardDecorationZone">
                <fieldset id="UploadDashboard">
                    <legend>Upload Dashboard</legend>
                    <telerik:RadUpload ID="UploadDashboardSelector" Runat="server" Width="235px" AllowedFileExtensions=".xml"  MaxFileInputsCount="1" ControlObjectsVisibility="None" />
                </fieldset>       
                <div class="BottomButton">
                    <telerik:RadButton ID="SubmitUploadDashboardButton" Runat="Server" Text="Upload" OnClientClicked="CloseUploadDashboard" /> 
                </div>
            </div>
        </ContentTemplate>
    </csw:UploadDashboardRadWindow>

    and the following server-side code:

    protected void Page_Init(object sender, EventArgs e)
    {
        if (Request.Files.Count > 0) HandleUploadedFile();
    }

    HandleUploadedFiles() works perfectly fine, but I am left with my Request's HTTPMethod set to POST and not GET. This means that if the user tries to refresh my Web Application they are prompted with a confirm form resubmission alert.

    Previously, I had fixed this with the following:

    Page.Response.Redirect(Page.Request.Url.ToString(), true);

    But new additions to my code makes this a non-acceptable solution. Namely, I have implemented Start Edit / Cancel Edit / Save Changes -- and refreshing the page is analogous to 'Cancel Edit.' As such, refreshing via code isn't a possibility.

    Could you show me how to parse an uploaded file while keeping the RadWindow wrapped in an update panel? Whenever I try to do it, Request.Files.Count is 0. 

    Thanks

  2. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 09 Nov 2011 Link to this post

    Hello Sean,

    Please note that it is not possible to use RadUpload control into update panel - limitation of the
    XmlHttpRequest object. You need to do a regular postback.
    For more details review the following help article.

    In case that the problem is not connected with described above, please provide me a working sample project that reproduces your issue.

    Kind regards,
    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Sean
    Sean avatar
    200 posts
    Member since:
    Nov 2010

    Posted 09 Nov 2011 Link to this post

    Hi Peter,

    No sample project to provide as it is reproducible on RadUpload - First Look. Go to this page, select any file and click upload. Now, refresh the page. 

    You will be prompted with a 'Confirm Form Resubmission' dialog, varying by browser. This is because Request's HTTPMethod is being left as 'POST' and not 'GET'.

    I would like to know how to craft my code such that this message does not occur without using the provided Response.Redirect code-snippet.

    I am OK with the initial page reload -- that is expected, but I would like the user to be able to refresh the page without any negative consequences.

    Sean
  5. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 11 Nov 2011 Link to this post

    Hi Sean,

    As far as I researched about resubmission of the form, I found out that the way to avoid resubmission is to implement PRG pattern and it is with redirection.

    I will be glad to assist you again.

    Best wishes,
    Peter Filipov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Back to Top