locked
Implementation of certain scopes in MVC RRS feed

  • Question

  • User-2102576357 posted

    The question is very generic but want to know certain implementations / testing of the following in MVC:

    1. How to implement JSON Signature
    2. Improvements, or check for bottleneck in terms of performance, security etc.
    3. Functionalities/areas, where TAP(Task Asynchronous Programming -async -await) can be enabled for better performance
    4. Enabling CORS in Web API.
    5. .Net Standard libraries with config file

    Any references or link suggestions would be great.

    Thanks In Advance!!!..

    Tuesday, August 13, 2019 1:08 PM

All replies

  • User1520731567 posted

    Hi sidd-mehta,

    I can provide some help on some issues.

    • Improvements, or check for bottleneck in terms of performance, security etc.

    From Data: optimize the sql algorithm and avoid loading large amounts of data at once.

    From code: optimize the query statement, lazy loading,you can use the cache appropriately.

    And you could use F12 developer tool Performance to check your website.

    • Enabling CORS in Web API.

    If you are wondering how to enable CORS in your Web API, you should install the Microsoft.AspNet.WebApi.Cors package, which is available on NuGet.

    In Visual Studio, select Library Package Manager from the Tools menu, and then select Package Manager Console. Write the following command in the console window:

    Install-Package Microsoft.AspNet.WebApi.Cors -pre -project WebService

    In the Solution Explorer, expand the WebApi project. Open the file App_Start/WebApiConfig.cs, and add the following code to the method WebApiConfig.Register.

    using System.Web.Http;
    namespace WebService
    {
        public static class WebApiConfig
        {
            public static void Register(HttpConfiguration config)
            {
                // New code
                config.EnableCors();
     
                config.Routes.MapHttpRoute(
                    name: "DefaultApi",
                    routeTemplate: "api/{controller}/{id}",
                    defaults: new { id = RouteParameter.Optional }
                );
            }
        }
    }

    Then add the attribute [EnableCors] to the desired controller.

    More details,you could refer to this article:

    https://www.hexacta.com/2014/09/15/How-to-enable-CORS-on-your-Web-API

    Hope these can be helpful to you.

    Best Regards.

    Yuki Tao

    Wednesday, August 14, 2019 3:19 AM