从@ Url.Action错误MVC4加载文本 [英] Load text from @Url.Action error MVC4

查看:84
本文介绍了从@ Url.Action错误MVC4加载文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用@ MvcHtmlString.Create加载文本(Url.Action(GetText,Text,new {urlId =802e0d33-4349-44e4-85d1-3b892e77598e}));但它唯一返回的是da / Text / GetText?urlId = 802e0d33-4349-44e4-85d1-3b892e77598e;从来没有采取行动。我应该说返回字符串包含html文本,如下面的控制器代码示例。这就是我使用MvcString.Create的原因这就是控制器中的动作如下:



Im trying to load text using @MvcHtmlString.Create(Url.Action("GetText", "Text", new { urlId ="802e0d33-4349-44e4-85d1-3b892e77598e" })); But the only thing it returns is da/Text/GetText?urlId=802e0d33-4349-44e4-85d1-3b892e77598e; and never gets to the action. I should say that the return string contains html text Like the example below the controller code. Which is the reason i''m using MvcString.Create This is how the action in the controller looks like:

public ActionResult GetText(string urlId)
    {
      SeoText model = new SeoText();
      model.Id = new Guid("802e0d33-4349-44e4-85d1-3b892e77598e");
      SeoText returnModel = this.GetSeoTextByUrl(model);

      return Content(returnModel.Description);
    }







<h2>Found a bug?</h2>
<p>If you think you have found a bug, you can use the <a href="../develop/bugtracker.php">Tracker</a> to report bugs to the developers.</p>
<p>And here is a simple table for you to play with.</p>
<table border="0">
<tbody>
<tr>
<td>Product</td>
<td>Cost</td>
<td>Really?</td>
</tr>

推荐答案

@ Html.Action [ ^ ]将创建一个网址,仅此而已。您需要ajax调用才能获得所需的内容。

你可以从这里开始: http:// automagical.rationalmind.net/2011/03/14/basic-ajax-with-mvc3-razor/ [ ^ ]
@Html.Action[^] will create the an url, nothing more. You will need an ajax call to get the content you need.
You could start here: http://automagical.rationalmind.net/2011/03/14/basic-ajax-with-mvc3-razor/[^]


这篇关于从@ Url.Action错误MVC4加载文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆