ASP.NET MVC Routing configuration giving Http 302 Object moved to -


i think might having bit of trouble mvc routing. note, i'm using asp.net mvc 4 razor views.

i have routes registered follows:

    routes.maproute(         "person",         "person/show/{uniqueid}",         new { controller = "person", action = "show", uniqueid = "" }         );      routes.maproute(         name: "default",         url: "{controller}/{action}/{id}",         defaults: new {controller = "home", action = "index", id = urlparameter.optional}         ); 

my personcontroller implemented follows:

[handleerror] public class personcontroller{     public actionresult show(string uniqueid)     {         //get data database         var persondata = getpersondatafromdatabase(uniqueid);          return view("personview", new personviewmodel(persondata));            } } 

this supposed display personview.cshtml has layout of _layoutcontent.cshtml in turn has layout of _layout.cshtml.

unfortunately, i'm unable see page.... unless i'm logged in. , have no idea why makes difference...

when try load page when i'm not logged in sent page:

http://mymachine:8083/?returnurl=%2fperson%2fshow%2fvxdwucay 

when @ happening using fiddler can see following happens:

  1. 302, http, mymachine:8083, /person/show/vxdwucay
  2. 200, http, mymachine:8038, /?returnurl=%2fperson%2fshow%2fvxdwucay

for http 302, can see returning following:

<html><head><title>object moved</title></head><body> <h2>object moved <a href="/?returnurl=%2fperson%2fshow%2fvxdwucay">here</a>.</h2> </body></html> 

can please point me in right direction of might causing issue? find strange being logged in causes route work. i'm sure must doing simple wrong...or i'm not looking in right place problem.

i found solution issue. able track problem down specific revision...and after lot of staring @ code able have epiphany solution.

i'm posting solution here in case else has problem in future.

in "personview" displaying partial view returning data follows:

@html.action("somelistpartial", "other") 

when reading that, in mind had mistakenly thought @html.actionlink method provides hyperlink page......the @html.action method instead "invokes specified child action method using specified controller name , returns results html string." ...which means executes action , gets resulting html display on screen.

when looked @ action being called, turns out had (correctly) placed [authorized] attribute on it...which why failing when not logged in.

now i'm not entirely sure why error wasn't more visible...but think there must buried in website redirect why automatically being taken ?returnurl=%2fperson%2fshow%2fvxdwucay


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -