c# - passing input text from view to contoller with FacebookContext using Facebook app -
I'm trying to pass an input text from the viewer to the controller in the Facebook Birthday app: Link to app:
In the Home Controller
[FacebookAuthorize ("email", "user_photos")] Public async Tasks & lt; ActionResult & gt; Index (FacebookContext reference) {if (ModelState.IsValid) {var user = waiting for reference. Client.Gate CurrentUserAsync & lt; MyAppUser & gt; (); View return (user); } See Return ("Error"); } [Http post] [facebook authorized ("email", "user_photo")) public async task & lieutenant; Actionsclass & gt; Index (string textile, facebookcontonte context) {if (ModelState.IsValid) {var user = wait context.Client.GetCurrentUserAsync & lt; MyAppUser & gt; (); // See my code, see the use of txt here (user); } See Return ("Error"); } View:
@using facebookpostc.models @ Microsoft.AspNet.Mvc.Facebook.models using @ Microsoft.AspNet.Mvc. Facebook @model MyAppUser @ {ViewBag.Title = "Home Page"; } & Lt; Article id = "content" & gt; & Lt; Div class = "right" & gt; @Using (HTML.benform ("index", "home controller")) {& lt; Br / & gt; & Lt; Span & gt; Please input your text: & lt; / Span & gt; & Lt; Input type = "text" id = "txt" name = "txt" /> & Lt; Input type = "submit" / & gt; } & Lt; / Div & gt; & Lt; / Article & gt; But this text is not passing, I tried to pass the text in many ways but none of them got the text.
You can read it from FormCollection : [http post] [facebook rights ("email", "user_photo")] public async work & lt; ActionResult & gt; Index (form collection form, facebook contact reference) {if (ModelState.IsValid) {string temp = form ["txt"]. ToString (); Var user = wait for reference. Client.GetCounter User Async & lt; MyAppUser & gt; (); // See my code, see the use of txt here (user); } See Return ("Error"); }
Comments
Post a Comment