小编TIK*_*KSN的帖子

在MVC4中显示和错误,我必须实现一些接口,但我已经完成了它

我正在尝试创建自己的过滤器属性,以支持多语言.这个想法很简单.URL代表语言.

  • *HTTP://host.ext/ EN/rest_of_the_url*将用英语开
  • *http://host.ext/ hy/rest_of_the_url*将以亚美尼亚语开放.

问题是在运行时它会说MultilingualActionFilterAttribute

以下是错误文本"给定的过滤器实例必须实现以下一个或多个过滤器接口:IAuthorizationFilter,IActionFilter,IResultFilter,IExceptionFilter".

在这里,我将它用作全局过滤器.

namespace TIKSN.STOZE.WebApp
{
    public class FilterConfig
    {
        public static void RegisterGlobalFilters(System.Web.Mvc.GlobalFilterCollection filters)
        {
            filters.Add(new TIKSN.STOZE.Common.MultilingualActionFilterAttribute());
            filters.Add(new System.Web.Mvc.HandleErrorAttribute());
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我在这里定义它.

namespace TIKSN.STOZE.Common
{
    public class MultilingualActionFilterAttribute : System.Web.Mvc.ActionFilterAttribute
    {
        public override void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext)
        {
            string language = System.Convert.ToString(filterContext.RouteData.Values["language"]);

            System.Diagnostics.Debug.Print("Requested language is '{0}'", language);
            language = Helper.PickUpSupportedLanguage(language);
            System.Diagnostics.Debug.Print("Supported language is '{0}'", language);

            if (language == string.Empty)
            {
                filterContext.HttpContext.Response.RedirectToRoutePermanent(new { language = Common.Properties.Settings.Default.DefaultLanguageCode });
            }

            language = Helper.TryToPickUpSupportedLanguage(language);

            System.Threading.Thread.CurrentThread.CurrentCulture = …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc multilingual inheritance interface-implementation

11
推荐指数
2
解决办法
8229
查看次数

PowerShell 二进制模块程序集依赖错误

我正在开发PowerShell 二进制模块。它使用Json.NET和其他库。

我收到此异常“无法加载文件或程序集 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' 或其依赖项之一。系统找不到指定的文件。”

在硬盘上,我有一个更新版本(版本 7.0.2)

像这样的问题在控制台、网络或桌面应用程序中很容易解决,通过这样的行使用app.config或“web.config”

<dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" culture="neutral" publicKeyToken="30ad4fe6b2a6aeed" />
    <bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
  </dependentAssembly>
Run Code Online (Sandbox Code Playgroud)

如何为 PowerShell 二进制模块做类似的事情?

c# powershell json .net-assembly

5
推荐指数
2
解决办法
1801
查看次数