• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 536
  • Last Modified:

mvc, razor

In controller:
public ActionResult Index()
            string inputState = Request.QueryString["inputState"];
            string inputBond = Request.QueryString["inputBond"];
            string userControlID = ServSuretyNetworkRef.GetBondUserControl(inputState, 1, inputBond);
            ViewBag.Message = userControlID;
            return View();

This one below does not work, and need help why and how to fix it? Thanks

However, the following is working
  • 3
1 Solution
Craig WagnerSoftware ArchitectCommented:
1. What does this have to do with Web Services and WCF? Please choose appropriate topics when posting questions.

2. "does not work" is pretty vague. Run-time error? Compiler error? No error but wrong results?

3. When I tried this I got a compiler error in the View. It stated that extension methods cannot be dynamically dispatched and I should consider casting the dynamic argument. So I did and it worked just fine.


Open in new window

solution1368Author Commented:
No model for this view it is in the shared folder

And my question is why it is working with the static string n not work in viewbag
solution1368Author Commented:
actually, i did test it and @Html.Partial((string)ViewBag.Message) solution is working to me.
adding (string) in the front of viewbag does resolve the string issue.

Thank you for your helps.
solution1368Author Commented:
Good lesson to learn for mvc viewbag.message. When a string parameter is passed from the controller to razor engine. Adding (string) will be resolved the debug issue.

Thank you for expert helping.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now