繁体   English   中英

我将在哪里将Page_Load的代码放在MVC SharePoint 2013提供程序托管的应用程序中?

[英]Where would I put the code for Page_Load in an MVC SharePoint 2013 provider hosted app?

我有一些来自ASP.NET Web应用程序的代码,该代码当前在页面之一中的Page_Load事件中。 我想将该代码移到我当前正在开发的用于访问SharePoint 2013服务器的新ASP.NET MVC应用程序中。 但是,我知道在MVC中不存在Page_Load事件。 我是否可以为此使用某种事件和/或控制器方法?

为了澄清起见,我要移动的代码将在执行任何Controller逻辑之前执行。 该代码用于在允许用户调用任何Controller方法之前检查SharePoint令牌。

任何帮助,将不胜感激。

将该代码放入自定义的“授权操作过滤器”中。

https://msdn.microsoft.com/zh-CN/library/gg416513(VS.98).aspx

public class CustomAuthorizationFilter : ActionFilterAttribute
{

    public override void OnActionExecuting(ActionExecutingContext filterContext)
    {

        //your authorization code goes here.

        base.OnActionExecuting(filterContext);
    }


}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM