草庐IT

Single-action

全部标签

c# - Asp.net mvc - 从自定义 Action 过滤器访问 View 模型

我正在尝试访问传递给操作过滤器OnActionExecuted中的View的模型数据。有谁知道这是否可能?我正在尝试做这样的事情:publicoverridevoidOnActionExecuted(ActionExecutedContextfilterContext){//getmodeldata//...sitemap.SetCurrentNode(model.Name);}有什么建议吗? 最佳答案 模型在:filterContext.Controller.ViewData.Model

c# - 我可以在 Action 或 Func 委托(delegate)中使用参数吗?

当我尝试在Action委托(delegate)中使用参数时...privateActionWriteToLogCallBack;我收到了这个设计时错误:Invalidtoken'params'inclass,struct,orinterfacememberdeclaration任何帮助! 最佳答案 这个解决方法怎么样?privateActionwriteToLogCallBack;publicvoidWriteToLogCallBack(strings,paramsobject[]args){if(writeToLogCallBac

c# - 我可以在 Action 或 Func 委托(delegate)中使用参数吗?

当我尝试在Action委托(delegate)中使用参数时...privateActionWriteToLogCallBack;我收到了这个设计时错误:Invalidtoken'params'inclass,struct,orinterfacememberdeclaration任何帮助! 最佳答案 这个解决方法怎么样?privateActionwriteToLogCallBack;publicvoidWriteToLogCallBack(strings,paramsobject[]args){if(writeToLogCallBac

c# - 无法从 'method group' 转换为 'System.Action<object>' 错误

我创建了以下函数:publicvoidDelegatedCall(ActiondelegatedMethod)并定义了如下方法publicvoidfoo1(Stringstr){}但是,当我尝试调用DelegateCall时与foo1:DelegatedCall(foo1);...我收到以下编译器错误:Argument1:cannotconvertfrom'methodgroup'to'System.Action'此错误的原因是什么,我该如何更正它?不幸的是,类型转换foo1至Action不是一个选项。 最佳答案 Delegated

c# - 无法从 'method group' 转换为 'System.Action<object>' 错误

我创建了以下函数:publicvoidDelegatedCall(ActiondelegatedMethod)并定义了如下方法publicvoidfoo1(Stringstr){}但是,当我尝试调用DelegateCall时与foo1:DelegatedCall(foo1);...我收到以下编译器错误:Argument1:cannotconvertfrom'methodgroup'to'System.Action'此错误的原因是什么,我该如何更正它?不幸的是,类型转换foo1至Action不是一个选项。 最佳答案 Delegated

c# - 如何描述返回值(非空值)的 Action<T> 委托(delegate)?

Action委托(delegate)返回无效。是否有任何其他返回非void值的内置委托(delegate)? 最佳答案 是的。Func返回指定为最终泛型类型参数的类型,例如Func返回int和Func接受一个整数并返回一个字符串。示例:FuncgetOne=()=>1;FuncconvertIntToString=i=>i.ToString();ActionprintToScreen=s=>Console.WriteLine(s);//usethemprintToScreen(convertIntToString(getOne())

c# - 如何描述返回值(非空值)的 Action<T> 委托(delegate)?

Action委托(delegate)返回无效。是否有任何其他返回非void值的内置委托(delegate)? 最佳答案 是的。Func返回指定为最终泛型类型参数的类型,例如Func返回int和Func接受一个整数并返回一个字符串。示例:FuncgetOne=()=>1;FuncconvertIntToString=i=>i.ToString();ActionprintToScreen=s=>Console.WriteLine(s);//usethemprintToScreen(convertIntToString(getOne())

c# - 将服务注入(inject) Action Filter

我正在尝试将服务注入(inject)到我的操作过滤器中,但我没有在构造函数中注入(inject)所需的服务。这是我所拥有的:publicclassEnsureUserLoggedIn:ActionFilterAttribute{privatereadonlyISessionService_sessionService;publicEnsureUserLoggedIn(){//Iwasunableabletoremovethedefaultctor//becauseofcompilationerrorwhileusingthe//attributeinmycontroller}publi

c# - 将服务注入(inject) Action Filter

我正在尝试将服务注入(inject)到我的操作过滤器中,但我没有在构造函数中注入(inject)所需的服务。这是我所拥有的:publicclassEnsureUserLoggedIn:ActionFilterAttribute{privatereadonlyISessionService_sessionService;publicEnsureUserLoggedIn(){//Iwasunableabletoremovethedefaultctor//becauseofcompilationerrorwhileusingthe//attributeinmycontroller}publi

请求500失败-No primary or single unique constructor found for interface xxx

错误:Noprimaryorsingleuniqueconstructorfoundforinterfacejava.util.List(没有为List接口找到主要的或唯一的构造函数)原因:请求的参数没有匹配上处理函数的参数解决:为List参数添加@RequestParam("strList")指定参数名称即可附加:本接口为测试异常接口,一般多个参数会封装为一个入参VO对象,使用JSON格式解析传入对象