How do I post to a webservice and display the returned Response in MVC3 Razor Application?
Posted
by
DavieDave
on Stack Overflow
See other posts from Stack Overflow
or by DavieDave
Published on 2012-05-30T19:35:38Z
Indexed on
2012/05/31
4:40 UTC
Read the original article
Hit count: 184
I have need to call a webservice from an HTML helper extension I created (combinbation of Action
and Image
) and placed in the view as follows
@Html.ActionImage("CallService", new { number = ViewBag.number, code = ViewBag.code, account = ViewBag.account, amount = ViewBag.amount }, "~/Content/sb_200x61.png", "Start the Process")
I am making the action call and it calls the service and returns a string of the html response, but it doesn't look right.
I am using the typical HttpWebRequest
to do the POST
Action in C# code.
Here is the controller action code:
public MvcHtmlString CallService(string number, string code, string account, decimal? amount)
{
string response = MyService.ServiceLayer.ClassName.callService(number, code, account, Convert.ToDecimal(amount);
MvcHtmlString mstring = new MvcHtmlString(response);
return mstring;
}
When it returns the string back it's looking like the all styling and js is removed.
It that due to MvcHtmlString
?
Is there a better way to do this?
Redirect somehow ?
© Stack Overflow or respective owner