Category Archives: asp.net-mvc-5

Getting this error while running ASP.NET MVC5 on mono apachee System.Web.Routing.RouteCollection.get_AppendTrailingSlash

Application Exception System.MissingMethodException Method not found: 'System.Web.Routing.RouteCollection.get_AppendTrailingSlash'.

Description: HTTP 500.Error processing request.

Details: Non-web exception. Exception origin (name of application or object): System.Web.Mvc. Exception stack trace: at System.Web.Mvc.RouteCollectionExtensions.GetVirtualPathForArea (System.Web.Routing.RouteCollection routes, System.Web.Routing.RequestContext requestContext, System.String name, System.Web.Routing.RouteValueDictionary values, System.Boolean& usingAreas) [0x00000] in :0 at System.Web.Mvc.RouteCollectionExtensions.GetVirtualPathForArea (System.Web.Routing.RouteCollection routes, System.Web.Routing.RequestContext requestContext, System.String name, System.Web.Routing.RouteValueDictionary values) [0x00000] in :0 at System.Web.Mvc.UrlHelper.GenerateUrl (System.String routeName, System.String actionName, System.String controllerName, System.Web.Routing.RouteValueDictionary routeValues, System.Web.Routing.RouteCollection routeCollection, System.Web.Routing.RequestContext requestContext, Boolean includeImplicitMvcValues) [0x00000] in :0 at System.Web.Mvc.Html.FormExtensions.BeginForm (System.Web.Mvc.HtmlHelper htmlHelper, System.String actionName, System.String controllerName,

error with mono, invalid IL Code System.ServiceModel.Security.Tokens.BinarySecretSecurityToken method body is empty

Im trying to deploy an asp .net mvc 5 application using apache + mod_mono on ubuntu 14.04 and im getting this error: Invalid IL code in System.ServiceModel.Security.Tokens.BinarySecretSecurityToken:.ctor (byte[]): method body is empty. this is the stack trace:

at Microsoft.Owin.Security.Jwt.SymmetricKeyIssuerSecurityTokenProvider..ctor (System.String issuer, IEnumerable`1 keys) <0x4165f510 + 0x00157> in <filename unknown>:0 
at Microsoft.Owin.Security.Jwt.SymmetricKeyIssuerSecurityTokenProvider..ctor (System.String issuer, System.Byte[] key) <0x4165f4a0 + 0x00053> in <filename unknown>:0
at myapplication.Startup.ConfigureOAuthTokenConsumption (IAppBuilder app) <0x4165e9f0 + 0x00193> in <filename unknown>:0
at myapplication.WebUI.Startup.Configuration (IAppBuilder app) <0x416308d0 + 0x0005f> in <filename unknown>:0 
at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&) 
at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) <0x40b97ec0 + 0x000b7> in <filename unknown>:0

and this is the code of my startup class:

    private void ConfigureOAuthTokenGeneration(IAppBuilder app)
    {
        // Configure the db context and user manager to use a single instance per request
        app.CreatePerOwinContext(ApplicationDbContext.Create);
        app.CreatePerOwinContext<ApplicationUserManager>(ApplicationUserManager.Create);
        app.CreatePerOwinContext<ApplicationRoleManager>(ApplicationRoleManager.Create);

        OAuthAuthorizationServerOptions OAuthServerOptions = new OAuthAuthorizationServerOptions()
        {
            //For Dev enviroment only (on production should be AllowInsecureHttp = false)
            AllowInsecureHttp = true,
            TokenEndpointPath = new PathString("/oauth/token"),
            AccessTokenExpireTimeSpan = TimeSpan.FromDays(1),
            Provider = new CustomOAuthProvider(),
            AccessTokenFormat = new CustomJwtFormat("http://localhost:80/")
        };

        // OAuth 2.0 Bearer Access Token Generation
        app.UseOAuthAuthorizationServer(OAuthServerOptions);
    }

    private void ConfigureOAuthTokenConsumption(IAppBuilder app) {

        var issuer = "http://localhost:80/";
        string audienceId = ConfigurationManager.AppSettings["as:AudienceId"];
        byte[] audienceSecret = TextEncodings.Base64Url.Decode(ConfigurationManager.AppSettings["as:AudienceSecret"]);

        // Api controllers with an [Authorize] attribute will be validated with JWT
        app.UseJwtBearerAuthentication(
            new JwtBearerAuthenticationOptions
            {
                AuthenticationMode = AuthenticationMode.Active,
                AllowedAudiences = new[] { audienceId },
                IssuerSecurityTokenProviders = new IIssuerSecurityTokenProvider[]
                {
                    new SymmetricKeyIssuerSecurityTokenProvider(issuer, audienceSecret)
                }
            });
    }

Does anyone know how to fix this error?