jquery - updating portion of asp.net MVc 4 view with partial view -
i working on asp.net mvc 4 application. have action link on main view this:
@ajax.actionlink("get linkedin profile","linkedin", new ajaxoptions { updatetargetid="partialdiv", // <-- dom element id update insertionmode = insertionmode.replace, // <-- replace content of dom element httpmethod = "get" // <-- http method }) <div id="partialdiv"></div>
and in controller, have action result performs redirection linkedin , returns action result.
public actionresult linkedin() { return redirect("https://www.linkedin.com/uas/oauth2/authorization?response_type=code&redirect_uri=" + httputility.htmlencode("http://127.0.0.1:81/account/linkedinauthorized")); }
now linkedinauthorized want return partialview or contents should inserted in partialdiv, doing this:
public actionresult linkedinauthorized(string code, string state) { // code here return partialview("linkedinprofileinfo", returnval); }
but replaces whole view instead of inserting partial view in div.
please suggest me solution this.
you need step , re-evaluate you're trying do. wouldn't hurt little more research ajax , oauth too, because you're not familiar concepts.
first, let's start oauth process. first, need direct user page on provider, in case, linkedin. there, user authorize provider, post designated page on site payload. application deciphers payload, storing relevant details, such auth token use in later requests, , process complete. can't done on ajax. once have auth token can whatever want ajax, initial authorization synchronous.
now, ajax. ajax can thought of simple http client. browser http client, more sophisticated. part of sophistication in providing seemless user experience, regardless of how many requests involved behind scenes. ajax, however, deals in simple request-response cycle. now, let's see why important difference.
a browser requesting linkedin
action
get /url/to/linkedin/action > http/1.1 302 > location: https://www.linkedin.com/uas/oauth2/authorization... https://www.linkedin.com/uas/oauth2/authorization... > http/1.1 200 > (crap ton of html)
ajax requesting linkedin
action:
get /url/to/linkedin/action > http/1.1 302 > location: https://www.linkedin.com/uas/oauth2/authorization...
see, browser knows since original url redirected, want go there, issues request redirected url. ajax makes no such assumptions. sent request , got response, it's done. it's issue ajax request proceed. so, if could use ajax oauth authorization, couldn't this.
Comments
Post a Comment