[英]Error: Child actions are not allowed to perform redirect actions
I used asp.net mvc 5. The action method is: 我使用了asp.net mvc5。该操作方法是:
public ActionResult GetRSSFeed(string rssfeed, string xslt)
{
try
{
XmlDocument xDoc = new XmlDocument();
xDoc.Load(rssfeed);
string returnhtml = ConvertXML(xDoc, Server.MapPath(xslt), new XsltArgumentList());
//InsertArticlesInDatabase(returnhtml);
return Content(returnhtml.
Replace(@"[[ This is a content summary only. Visit my website for full links, other content, and more! ]]",
""));
}
catch
{
return Content("");
}
}
The code in view is: 视图中的代码是:
Html.Action("GetRSSFeed", "RSSReader", new { rssfeed = Model.RssFeed.ToString(),xslt = Url.Content(Model.XsltTransformation.ToString()), area = "RSSReader" })
When exception is appear the execution does not go in the code in controller. 当出现异常时,执行不会进入控制器的代码中。
How can I fix this error, and why that error appear? 如何解决此错误,为什么会出现该错误? The code in controller does not redirect anywhere, it just return pure html.
控制器中的代码不会重定向到任何地方,而只是返回纯HTML。
Looks to be a repeat of this: Look here 看起来是这样的重复: 看这里
This happened to mea few times because I had [RequireHttps] on the Controller, and a child action was called from a different controller. 因为我在Controller上有[RequireHttps],并且从另一个控制器调用了一个子动作,所以发生了几次。 The RequireHttps attribute caused the redirect
RequireHttps属性导致重定向
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.