简体   繁体   English

错误:子操作不允许执行重定向操作

[英]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.

相关问题 子操作不允许执行重定向操作错误 - Child actions are not allowed to perform redirect actions error 子操作不允许执行重定向操作 - Child actions are not allowed to perform redirect actions “不允许子操作执行重定向操作” - “Child actions are not allowed to perform redirect actions” 子操作不允许执行重定向操作。 (使用PartialViews) - Child actions are not allowed to perform redirect actions. (Using PartialViews) 子操作不允许执行重定向操作MVC4 - Child actions are not allowed to perform redirect actions MVC4 ASP.NET MVC 3 + Razor错误:不允许子操作执行重定向操作 - ASP.NET MVC 3 + Razor Error: Child actions are not allowed to perform redirect actions 在部分视图控制器中无法正常工作。(错误 - 不允许子操作执行重定向操作。) - doesn't work redirecttoaction in partial view controller.(Error - Child actions are not allowed to perform redirect actions.) 不允许子操作执行重定向操作 - 使用ASP.NET MVC 2和Razor时出错 - Child actions are not allowed to perform redirect actions - error while working with ASP.NET MVC 2 and Razor 如何解决不允许子操作执行重定向操作,其他答案不解决 - How to fix Child actions are not allowed to perform redirect actions, other answers does not fix 重定向到区域操作中的操作 - Redirect to action in area actions
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM