Click here to Skip to main content
15,885,216 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Directory name invalid error in asp.net Pin
Richard Deeming25-Oct-17 4:41
mveRichard Deeming25-Oct-17 4:41 
Questioncustom paging Pin
netbrain software22-Oct-17 0:29
netbrain software22-Oct-17 0:29 
AnswerRe: custom paging Pin
Richard Deeming24-Oct-17 2:02
mveRichard Deeming24-Oct-17 2:02 
QuestionWhat is ASP.net roadmap for a beginner? Pin
Dinxen20-Oct-17 6:08
Dinxen20-Oct-17 6:08 
AnswerRe: What is ASP.net roadmap for a beginner? Pin
Richard Deeming20-Oct-17 6:20
mveRichard Deeming20-Oct-17 6:20 
QuestionCustom Tablix Sort Order Z-A Pin
jkirkerx19-Oct-17 11:30
professionaljkirkerx19-Oct-17 11:30 
AnswerRe: Custom Tablix Sort Order Z-A Pin
jkirkerx19-Oct-17 11:38
professionaljkirkerx19-Oct-17 11:38 
QuestionMVC RedirectToRouteResult Help Pin
Foothill18-Oct-17 9:23
professionalFoothill18-Oct-17 9: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:
C#
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:
C#
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 9:51
mveRichard Deeming18-Oct-17 9:51 
GeneralRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 3:23
professionalFoothill19-Oct-17 3:23 
GeneralRe: MVC RedirectToRouteResult Help Pin
Richard Deeming19-Oct-17 9:25
mveRichard Deeming19-Oct-17 9:25 
GeneralRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 10:58
professionalFoothill19-Oct-17 10:58 
GeneralRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 4:44
professionalFoothill19-Oct-17 4:44 
GeneralRe: MVC RedirectToRouteResult Help Pin
Richard Deeming19-Oct-17 9:18
mveRichard Deeming19-Oct-17 9:18 
PraiseRe: MVC RedirectToRouteResult Help Pin
Foothill19-Oct-17 10:59
professionalFoothill19-Oct-17 10:59 
QuestionPassword Reset works in debug environment but does not work after deployment Pin
Philip Hall16-Oct-17 6:50
Philip Hall16-Oct-17 6:50 
AnswerRe: Password Reset works in debug environment but does not work after deployment Pin
A_Griffin18-Oct-17 21:49
A_Griffin18-Oct-17 21:49 
GeneralRe: Password Reset works in debug environment but does not work after deployment Pin
Philip Hall19-Oct-17 5:10
Philip Hall19-Oct-17 5:10 
Generalcode for solving zero distortion tecniqueof image steganography Pin
Member 1346535714-Oct-17 9:43
Member 1346535714-Oct-17 9:43 
SuggestionRe: code for solving zero distortion tecniqueof image steganography Pin
Kornfeld Eliyahu Peter14-Oct-17 22:53
professionalKornfeld Eliyahu Peter14-Oct-17 22:53 
QuestionCode is inserting only one row of records. Any ideas? Pin
samflex9-Oct-17 5:16
samflex9-Oct-17 5:16 
AnswerRe: Code is inserting only one row of records. Any ideas? Pin
F-ES Sitecore11-Oct-17 0:54
professionalF-ES Sitecore11-Oct-17 0:54 
AnswerRe: Code is inserting only one row of records. Any ideas? Pin
ZurdoDev11-Oct-17 9:44
professionalZurdoDev11-Oct-17 9:44 
QuestionHave a form result invisible until submission? Pin
The Rarispy8-Oct-17 16:48
The Rarispy8-Oct-17 16:48 
AnswerRe: Have a form result invisible until submission? Pin
Richard Deeming9-Oct-17 8:42
mveRichard Deeming9-Oct-17 8: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.