Home > Net >  Found the problem, the inheritance of controller have interceptors, but no execution, is what went w
Found the problem, the inheritance of controller have interceptors, but no execution, is what went w

Time:04-30

To my convenience, on a few have inherited the same controller in the controller, and add a interceptors in the inheritance of controller, but the interceptor is ignored, the reason why

Such as this be inherited controller for
 [NeedLogin]//this is interceptor 
Public class MyBaseController: ControllerBase
{

Public MyBaseController ()
{
String b="dd";

}
}


Then the inheritance he, but invalid
 
Public class HouseController: MyBaseController
{

///& lt; Summary>
///property list
///& lt;/summary>
///& lt; Param name="L" & gt;
///& lt; Returns>

[HttpPost]
Public IActionResult getHouseList (ListModel L)
{

Return the Content (" HuaMuCheng beds hand since the plant ")));

}


CodePudding user response:

I've only been learning, inheritance, derivation, and multiple inheritance,

You write of what? Even the inheritance, you really can invent,

CodePudding user response:

What is your features Inherited

CodePudding user response:





reference 1st floor morliz son hin reply:
I've only been learning, inheritance, derivation and multiple inheritance,

You write of what? Even the inheritance, you really can invent,


Excuse me, how to say, citing MyBaseController after this class, is indeed can run MyBaseController inside the constructor, but in front of [NeedLogin] is ignored

CodePudding user response:

reference 1st floor morliz son hin reply:
I've only been learning, inheritance, derivation and multiple inheritance,

You write of what? Even the inheritance, you really can invent,


Or let me put it this way, I have a few controller need this [NeedLogin] interceptor (not global), but I don't want to in each controller class name plus the above [NeedLogin], feel is too LOW, so think what method, a bit more concise

CodePudding user response:

Goodgame365
reference 4 floor response:
Quote: refer to 1st floor morliz son hin reply:
I've only been learning, inheritance, derivation and multiple inheritance,

You write of what? Even the inheritance, you really can invent,


Or let me put it this way, I have a few controller need this [NeedLogin] interceptor (not global), but I don't want to in each controller class name plus the above [NeedLogin], feel is too LOW, so think what method, a bit more concise


This sentence, just Get the point,
To all classes inherit, mount the [vehicle], that is, directly write a base class with interceptors,

Inheritance in each derived class, the base class, intuitive, do you think of it

CodePudding user response:

reference 5 floor morliz son hin reply:
Quote: refer to 4th floor goodgame365 response:
Quote: refer to 1st floor morliz son hin reply:
I've only been learning, inheritance, derivation and multiple inheritance,

You write of what? Even the inheritance, you really can invent,


Or let me put it this way, I have a few controller need this [NeedLogin] interceptor (not global), but I don't want to in each controller class name plus the above [NeedLogin], feel is too LOW, so think what method, a bit more concise


This sentence, just Get the point,
To all classes inherit, mount the [vehicle], that is, directly write a base class with interceptors,

Inheritance in each derived class, the base class, intuitive, do you think of it complicated


Can you simple example, I stink!

CodePudding user response:

refer to 6th floor goodgame365 response:
can you simple example, I stink!

See demo:
 
[abstraction layer base class] for data access layer and the BLL layer between the base class method
The namespace CusPro. Framework. ControlUtil
{
///& lt; Summary>
///the data Access layer of the base class, all of the database Access to data base classes are inherited from the super base classes, including Oracle, essentially, Sqlite, MySql, Access etc.
///& lt;/summary>
Public abstract class AbstractBaseDAL Where T: BaseEntity, new ()
{}
}

[data layer entity base class]
The namespace CusPro. Framework. ControlUtil
{
///& lt; Summary>
///frame entity class base class
///& lt;/summary>
[DataContract]
Public class BaseEntity
{}
}
[] access to the underlying interface
The namespace CusPro. Framework. ControlUtil
{
///& lt; Summary>
///the data access layer interface
///& lt;/summary>
Public interface IBaseDAL T: where BaseEntity
{}
}
[the data access layer base class]
The namespace CusPro. Framework. ControlUtil
{
///& lt; Summary>
///the data access layer of the base class
///& lt;/summary>
Public abstract class BaseDALSQL : AbstractBaseDAL IBaseDAL Where T: BaseEntity, new ()
{}
}
[the data access layer - & gt; method of entity class] inherit the data access layer base class
The namespace CusPro. Dictionary. DALSQL
{
///& lt; Summary>
///City descriptions,
///& lt;/summary>
Public class City: BaseDALSQL ICity,
{}
}


Don't understand the question again,

CodePudding user response:

Have a look at a simple example

BitmapSource inherited, all the way from the most basic object in the middle of each layer to realize their respective functions, consistent with the way of the building Lord, didn't see what's the problem.


refer to the second floor morning to evening reply:
what is your features Inherited

Also gives the key information, should check NeedLogin. Inherited attribute's value, it can determine whether or not the subclass from the parent class to inherit the Atrribute

Refer to
https://docs.microsoft.com/zh-cn/dotnet/api/system.attributeusageattribute.inherited? View=.net 5.0

CodePudding user response:

Busy guess Atrribute should [NeedLogin (Inherited=true)]
  •  Tags:  
  • C#
  • Related