Click here to Skip to main content
14,766,440 members
Home » Discussions » ASP.NET
   

ASP.NET

 
GeneralRe: Directory name invalid error in asp.net Pin
Richard Deeming25-Oct-17 5:41
mveRichard Deeming25-Oct-17 5:41 
Questioncustom paging Pin
netbrain software22-Oct-17 1:29
Membernetbrain software22-Oct-17 1:29 
AnswerRe: custom paging Pin
Richard Deeming24-Oct-17 3:02
mveRichard Deeming24-Oct-17 3:02 
QuestionWhat is ASP.net roadmap for a beginner? Pin
Dinxen20-Oct-17 7:08
MemberDinxen20-Oct-17 7:08 
AnswerRe: What is ASP.net roadmap for a beginner? Pin
Richard Deeming20-Oct-17 7:20
mveRichard Deeming20-Oct-17 7:20 
QuestionCustom Tablix Sort Order Z-A Pin
jkirkerx19-Oct-17 12:30
professionaljkirkerx19-Oct-17 12:30 
AnswerRe: Custom Tablix Sort Order Z-A Pin
jkirkerx19-Oct-17 12:38
professionaljkirkerx19-Oct-17 12:38 
QuestionMVC RedirectToRouteResult Help Pin
Foothill18-Oct-17 10:23
professionalFoothill18-Oct-17 10:23 
I am trying to build a dictionary of RedirectToRouteResults.

Background:
I am building a web application. Once a user gets past the login, the server returns an encrypted session cookie that follows the user around and is used to display user specific information on each page. Pretty standard fair. Now, the problem is that each Controller Action performs a check on the cookie to check for tampering, if the user's session has expired, if the user is authorized for this page, etc... so each controller has to handle a half-dozen different return types from the security check function. I could handle this with a switch...case in the catch block of each controller's code but that seems sloppy.

The Question:
I am having trouble figuring out how I can build a Dictionary of redirect routes to simplify this. I haven't been able to find anything on the internet in the way of an example for properly building a RedirectToRouteResult object that can be returned in a controller.

Instead of this:
public ActionResult Index()
{
 SecurityCheck secCheck = ValidateConnection(this);

 if (secCheck != secCheck.Okay)
 {
  switch (secCheck)
  {
   case SecurityCheck.AuthenticationFailure:
    return RedirectToAction("Default", "ErrorHandler", new { message = "Not Authorized." });
    // and so on....
  }
 }
}

I would like to simplify it to:
public ActionResult Index()
{
 SecurityCheck secCheck = ValidateConnection(this);

 if (secCheck != secCheck.Okay)
 {
  return SecurityRedirect.Routes[secCheck]; 
  // SecurityRedirect would be a static class that would contain
  // a dictonary of the how each security issue should be redirected.
 }
 else
 {
  return View();
 }
}

Is there a way? I am having no luck figuring out how to build a RedirectToRouteResult as the documentation on it is Spartan at best. I do believe that they would accomplish my goal.
if (Object.DividedByZero == true) { Universe.Implode(); }
Meus ratio ex fortis machina. Simplicitatis de formae ac munus. -Foothill, 2016

SuggestionRe: MVC RedirectToRouteResult Help Pin
Richard Deeming18-Oct-17 10:51
mveRichard Deeming18-Oct-17 10:51 
GeneralRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 4:23
professionalFoothill19-Oct-17 4:23 
GeneralRe: MVC RedirectToRouteResult Help Pin
Richard Deeming19-Oct-17 10:25
mveRichard Deeming19-Oct-17 10:25 
GeneralRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 11:58
professionalFoothill19-Oct-17 11:58 
GeneralRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 5:44
professionalFoothill19-Oct-17 5:44 
GeneralRe: MVC RedirectToRouteResult Help Pin
Richard Deeming19-Oct-17 10:18
mveRichard Deeming19-Oct-17 10:18 
PraiseRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 11:59
professionalFoothill19-Oct-17 11:59 
QuestionPassword Reset works in debug environment but does not work after deployment Pin
Philip Hall16-Oct-17 7:50
MemberPhilip Hall16-Oct-17 7:50 
AnswerRe: Password Reset works in debug environment but does not work after deployment Pin
A_Griffin18-Oct-17 22:49
MemberA_Griffin18-Oct-17 22:49 
GeneralRe: Password Reset works in debug environment but does not work after deployment Pin
Philip Hall19-Oct-17 6:10
MemberPhilip Hall19-Oct-17 6:10 
Generalcode for solving zero distortion tecniqueof image steganography Pin
Member 1346535714-Oct-17 10:43
MemberMember 1346535714-Oct-17 10:43 
SuggestionRe: code for solving zero distortion tecniqueof image steganography Pin
Kornfeld Eliyahu Peter14-Oct-17 23:53
professionalKornfeld Eliyahu Peter14-Oct-17 23:53 
QuestionCode is inserting only one row of records. Any ideas? Pin
samflex9-Oct-17 6:16
Membersamflex9-Oct-17 6:16 
AnswerRe: Code is inserting only one row of records. Any ideas? Pin
F-ES Sitecore11-Oct-17 1:54
mveF-ES Sitecore11-Oct-17 1:54 
AnswerRe: Code is inserting only one row of records. Any ideas? Pin
ZurdoDev11-Oct-17 10:44
professionalZurdoDev11-Oct-17 10:44 
QuestionHave a form result invisible until submission? Pin
The Rarispy8-Oct-17 17:48
MemberThe Rarispy8-Oct-17 17:48 
AnswerRe: Have a form result invisible until submission? Pin
Richard Deeming9-Oct-17 9:42
mveRichard Deeming9-Oct-17 9:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.