• . net MVC use session to verify user login (4)


    Record user login status in the simplest session mode 1. Add defaultcontroller controller, override onactionexecuting method, and trigger before each access to controller public class DefaultController : Controller { protected override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); var controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName; var userName = Session[“UserName”] as String; if (String.IsNullOrEmpty(userName)) { //Redirect to login page filterContext.Result = […]

  • . net MVC uses iprincipal for form login, namely authority verification (3)


    . net MVC uses iprincipal to perform form login, i.e. authority verification, for your reference. The details are as follows 1. Add user class in MVC project, and add necessary attributes according to actual project requirements public class UserData { /// <summary> /// ID /// </summary> public int UserId { get; set; } /// <summary> […]

  • . net unity IOC framework use case details


    . net unity IOC framework, as follows 1.IOC introduction IOC (inversion of control) Di (dependency injection) The basic concept of IOC is: do not create objects, but describe how to create them. Do not connect directly to objects and services in code, but describe which component requires which service in the configuration file. The container […]

  • . net WCF simple example details (5)


    This article shares a simple example of. Net WCF for your reference. The specific content is as follows 1. Create WCF project 2. The system automatically generates IWCFService //Note: using the rename command on the refactoring menu, you can change the interface name iservice1 in both the code and the configuration file. [ServiceContract] public interface […]

  • Detailed explanation of. Net MSMQ message queue instance


    This article shares the. Net MSMQ message queue instance code for your reference. The specific content is as follows 1. Installation of MSMQ message queuing Windows Environment Control panel —– programs and functions —– enable or close windows programs —– Microsoft message queue (MSMQ) server Select the function as shown in the figure and click […]

  • A detailed explanation of several class libraries commonly used in. Net core project (worth collecting)


    Preface It has been nearly 15 years since Microsoft launched. Net platform in 2002. In the wave of rapid Internet iteration, many languages have been eliminated, and more new languages have emerged. But. Net is still firmly standing in the front-line camp of system development platform, and with the arrival of the official version of. […]

  • . net core uses openxml to export and import Excel


    Exporting excel is a very common function of programs. Net core can export excel with the help of open XML SDK. Open-XML-SDK Open XML SDK is an open source project of Microsoft. The open XML SDK is an open source class library for open XML documents (docx, xlsx, and pptx). It can: Very good performance […]

  • Set sorting in. Net can play like this, you know


    Overview of C-SET types Collection is an important part of. Net FCL (Framework Class Library). All collection classes inherit from IEnumerable. Collection classes can be divided into the following categories: Association / non association type collection, sequential / random access collection, sequential / unordered collection, generic / non generic collection, thread safety collection. Bottom interface […]

  • Exception handling in MVC


    1、 Application scenario For B / s applications, in the process of deployment to the formal environment for operation, there are likely to be some exceptions or errors not found in the early test process, or some exceptions only occur when certain conditions are met. For application sites developed with MVC, after deployment to […]

  • Setting method of cookie domain when IIS implements reverse proxy


    Reverse proxy Is Shenma a reverse agent? It refers to that the proxy server accepts the connection request on the Internet, then forwards the request to the server on the internal network, and returns the result obtained from the server to the client requesting the connection on the Internet. At this time, the proxy server […]

  • implementation of 301 redirection method


    <span style= “font-family:’Tahoma’; font-size:10.5pt;” ></span> On Baidu and other search engines for the “www” prefix domain name identification problem: that is, search engines will identify and as two different domain names, the consequences of this is to disperse the attention of the website, is not conducive to the publicity and promotion of the […]

  • core uses urlfirewall to filter requests


    I. Preface Urlfirewall is an open-source and lightweight middleware for filtering HTTP requests. It can be used in webapi or gateway (such as Ocelot), written by myself, and open-source in GitHub: (local download) 2、 Introduction to urlfirewall Urlfirewall is an HTTP request filtering middleware, which can be matched with the gateway (Ocelot) to shield […]