我在Umbraco平台下,用MVC(SurfaceController)开发时,遇到这个问题

MemberEdit是一个partial View

[HttpGet]
[ActionName("MemberEdit")]
public ActionResult MemberEditGet()
{
if (Members.GetCurrentLoginStatus().IsLoggedIn)
{ var currentProfileModel = new Gallagher.Fuelsystems.Core.Models.ProfileModel()
{ // some codes here
}; return PartialView("MemberEdit", currentProfileModel); } else
{
return PartialView("MemberLogin"); //return Redirect("/Login");
} }

刚开始,在else语句中,我使用的是 return Redirect("/Login"); 就报这个错误,后来我改为 return PartialView("MemberLogin"); 就没问题了

在网上搜索了关于这个错误信息,解释大概如下:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

The limitation exists because MVC has already started rendering a view to the client. The effect of redirecting from this point is undefined. It could work perfectly, it could continue rendering the original view without redirecting, it could throw a different exception, etc.

Since the result of performing this action is undefined, the framework blocks it. In practice, RenderAction should never be used to render anything other than a view (or view-like content) for similar reasons.

In your particular case, the outer action should redirect. If you're just going to end up redirecting from within the view anyway without showing anything to the user, then there was really no purpose to going through the view in the first place, as the outer action could have delegated the work appropriately on its own.

The redirect info is stored in response header. However, the response is already being sent when child action is run so headers can't be written.

-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

[ASP.NET MVC] Child actions are not allowed to perform redirect的更多相关文章

  1. ASP.NET MVC之"重定向/页面跳转"(关键词RedirectToAction,Redirect)

    MVC5 API(官方) 1.RedirectToRouteResult RedirectToAction(string actionName); RedirectToRouteResult Redi ...

  2. [转载]深入理解ASP.NET MVC之ActionResult

    Action全局观 在上一篇最后,我们进行到了Action调用的“门口”: 1 if (!ActionInvoker.InvokeAction(ControllerContext, actionNam ...

  3. 深入理解ASP.NET MVC(6)

    系列目录 Action全局观 在上一篇最后,我们进行到了Action调用的“门口”: 1 if (!ActionInvoker.InvokeAction(ControllerContext, acti ...

  4. [ASP.NET MVC 小牛之路]12 - Section、Partial View 和 Child Action

    概括的讲,View中的内容可以分为静态和动态两部分.静态内容一般是html元素,而动态内容指的是在应用程序运行的时候动态创建的内容.给View添加动态内容的方式可归纳为下面几种: Inline cod ...

  5. [转][ASP.NET MVC 小牛之路]12 - Section、Partial View 和 Child Action

    本文转自:http://www.cnblogs.com/willick/p/3410855.html 概括的讲,View中的内容可以分为静态和动态两部分.静态内容一般是html元素,而动态内容指的是在 ...

  6. Professional C# 6 and .NET Core 1.0 - Chapter 41 ASP.NET MVC

    What's In This Chapter? Features of ASP.NET MVC 6 Routing Creating Controllers Creating Views Valida ...

  7. [转]ASP.NET MVC 5 List Editor with Bootstrap Modals

    本文转自:https://www.codeproject.com/articles/786085/asp-net-mvc-list-editor-with-bootstrap-modals With ...

  8. [Asp.net mvc]OutputCacheAttribute

    什么是Cache? 缓存在web应用中是一种以空间换去时间的技术,把频繁访问并且不经常变化的数据存储到内存中,以达到快速访问的目的.在web应用中是比较常见的优化方式. OutputCacheAttr ...

  9. 【ASP.NET MVC 5】第27章 Web API与单页应用程序

    注:<精通ASP.NET MVC 3框架>受到了出版社和广大读者的充分肯定,这让本人深感欣慰.目前该书的第4版不日即将出版,现在又已开始第5版的翻译,这里先贴出该书的最后一章译稿,仅供大家 ...

随机推荐

  1. 装个Redmine真是麻烦啊

    弄个大半天终于看到这个界面出来了,不容易啊

  2. UVa 253 Cube paiting

    题意:输入两个骰子,判断是否等价 因为每一个面可以作顶面,共6*4种情况,枚举就可以了 #include<iostream> #include<cstdio> #include ...

  3. Html5大文件断点续传

    大文件分块   一般常用的web服务器都有对向服务器端提交数据有大小限制.超过一定大小文件服务器端将返回拒绝信息.当然,web服务器都提供了配置文件可能修改限制的大小.针对iis实现大文件的上传网上也 ...

  4. I.MX6 Ethernet UI patch failed

    /*********************************************************************** * I.MX6 Ethernet UI patch f ...

  5. FZU 1591 Coral的烦恼

    Problem Description 程序设计课的老师给Coral布置了一道题:用T(n)表示所有能整除n的正整数之和,对于给定的数字n,记S(n)=T(1)+T(2)+…+ T(n).你的任务就是 ...

  6. ORACLE远程连接数据库

    1. sqlplus sqlnet.ora 文件格式NAMES.DIRECTORY_PATH= (TNSNAMES,HOSTNAME).客户端就会首先在tnsnames.ora文件中找orcl的记录. ...

  7. 五分钟solr4.5教程(搭建、运行)

    环境要求 jdk1.6及以上版本 solr发布版本 下载地址 http://lucene.apache.org/solr/mirrors-solr-latest-redir.html? 启动solr ...

  8. MySQL基础之第6章 创建、修改和删除表 .

    6.1.创建表 6.1.1.创建表的语法形式 CREATE TABLE 表名 ( 属性名 数据类型 [完整性约束条件],属性名 数据类型 [完整性约束条件],...... 属性名 数据类型); 完整性 ...

  9. MOSS 2010:Visual Studio 2010开发体验(14)——列表开发之事件接收器

    转:http://boke.25k5.com/kan141919.html 通过前面几篇,我们已经完成了内容类型,列表定义,列表实例g 8h"@的开发.本篇继续讲解列表中的一个重要环节- ...

  10. Nmap / NetCat(nc) / 网络安全工具

    nmap - 网络探测工具和安全/端口扫描器 nmap [ <扫描类型> ...] [ <选项> ] { <扫描目标说明> } 描述 Nmap ("Net ...