Child actions are not allowed to perform redirect actions. (Using PartialViews)

前端 未结 4 1728
隐瞒了意图╮
隐瞒了意图╮ 2021-01-24 00:26

I\'m trying to load my partial view with some data from database, but I\'m getting following issue when I run the application:

Child actions are not allo

4条回答
  •  逝去的感伤
    2021-01-24 01:18

    The error is pretty explicit. Child actions cannot issue redirects. This is because, while child actions look like regular actions, they are in fact rendered in a separate process and cannot modify the actual response (which a redirect would require).

    In your actual child action code, you're not returning a redirect, so that means you must have an action filter being applied to the child action that is issuing the redirect. In particular, you should avoid using things like Authorize or RequireHttps on child actions, as those work by using redirects, which again, a child action cannot do. If the child action is in a controller that is decorated with Authorize, it should be marked with AllowAnonymous.

提交回复
热议问题