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

I have a screen where at top it has a fiscal period dropdown and when changed it should redirect me to same screen but for the year selected.

Issue : I have upload functionality on that view. upload functionality calls the post method say "actionmethod1" and the screen comes from "actionmethod2". so when i do upload the url is /actionmethod1 and when i select dropdown it will take to last action method invoked i.e actionmethod1 and saw it throws error as resource not found.

code being used for redirecting in jquery :
@HttpContext.Current.Request.RequestContext.RouteData.

it calls the post action method of upload and throws an error.


we are using kendo upload functionality which uses
form method="post" action='@Url.Action("Upload", "controllername")'>

so how to navigate the same screen using actionname of the screen

What I have tried:

I am trying to use UrlReferrer method to get parent or earlier actionmethod and controller name so that it takes me to same view.

issue is

1) i am unable to check if exists on request.urlReferrer. It is failing always

if(Request.UrlReferrer !== null)   
                    {
                        var path = @HttpContext.Current.Request.UrlReferrer.LocalPath.ToString();
                    }

But for some reason even for null UrlReferrer it is satifying if condition and getting null exception error.


2. Is it good to use urlReferrer as it is client side. Are there any other suggestions providing how to navigate through..

Thank you
Posted
Updated 2-Jun-17 11:18am
v3
Comments
F-ES Sitecore 26-May-17 4:21am    
Not sure I understand the question, but if you want the form to always post to the current url then leave the "action" attribute off

<form method="post">

1 solution

I resolved by storing the viewdata.modelstate in tempdata and restoring it again from tempdata while redirecting to same view. I created action filter for setting tempdata and restoring from tempdata for reusability.

Below two links helped me :


What is the ModelState? - ASP.NET MVC Demystified[^]

Jef Claes: Persisting model state when using PRG[^]
 
Share this answer
 

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