【问题标题】:Error: Child actions are not allowed to perform redirect actions错误:不允许子操作执行重定向操作
【发布时间】:2017-08-15 13:46:43
【问题描述】:

我用的是asp.net mvc 5,动作方法是:

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("");
    }
}

视图中的代码是:

Html.Action("GetRSSFeed", "RSSReader", new { rssfeed = Model.RssFeed.ToString(),xslt = Url.Content(Model.XsltTransformation.ToString()), area = "RSSReader" })

当出现异常时,控制器中的代码不会执行。

我该如何解决这个错误,为什么会出现这个错误?控制器中的代码不会重定向到任何地方,它只是返回纯 html。

【问题讨论】:

标签: c# asp.net-mvc


【解决方案1】:

看起来是这样的重复: Look here

这发生过几次,因为我在控制器上有 [RequireHttps],并且从不同的控制器调用了一个子操作。 RequireHttps 属性导致了重定向

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-12-29
    相关资源
    最近更新 更多