C # The MVC search for the corresponding controller first looks for the current domain
If you cannot find it, you will find an alternative ..
But sometimes we don't want him to look for a Slave controller.
A datatoken is involved here.
Routes. maproute (
"Default", // route name
"{Controller}/{action}/{ID}", // URL with Parameters
New {controller = "home", Action = "Index", id = urlparameter. optional}, // parameter defaults
New String [] {"Reader. controllers "}
);
For the first time, I used new string to differentiate them. Unfortunately, he will still search for them. After reading some documents
If you want to cancel the backup controller, you need to write it like this.
Routes. maproute (
"Default", // route name
"{Controller}/{action}/{ID}", // URL with Parameters
New {controller = "home", Action = "Index", id = urlparameter. optional}, // parameter defaults
New String [] {"Reader. controllers "}
). Datatokens ["usenamespacefallback"] = false;
In this way, the Standby controller operation is canceled.
Back up some MVC conventions.
Protected override void onmodelcreating (dbmodelbuilder modelbuilder)
{
// DB. contextoptions. lazyloadingenabled = false;
// DB. contextoptions. proxycreationenabled = false;
Modelbuilder. Conventions. Remove <pluralizingtablenameconvention> (); // remove the contract with the complex table name
Modelbuilder. Conventions. Remove <includemetadataconvention> ();
Base. onmodelcreating (modelbuilder );
/*
The following conventions can be deleted:
Namespace: system. Data. entity. modelconfiguration. Conventions. EDM
• Associationinversediscoveryconvention
Search for the attributes of the classes referenced in the navigation and configure them as the same relationship of the inverse attributes.
• Complextypediscoveryconvention
Find the types with or without primary keys and configure them as complex types.
• Declaredpropertyorderingconvention
Ensure that the primary key attributes of each object take precedence over other attributes.
• Foreignkeyassociationmultiplicityconvention
Whether the configuration is required or optional is based on the null foreign key attribute, if included in the class definition.
• Idkeydiscoveryconvention
Search for the attributes named ID or <typename> ID and configure them as the primary key.
• Navigationpropertynameforeignkeydiscoveryconvention
Use the foreign key relationship and the <navigationproperty> <primarykeyproperty> mode as the attribute appearance.
• Onetomanycascadedeleteconvention
The relationship required for the switch to be deleted.
• Onetooneconstraintintroductionconvention
It is configured as a primary key for a foreign key of a link.
• Pluralizingentitysetnameconvention
Name of the entity set in the object data model configured as a diverse type name.
• Primarykeynameforeignkeydiscoveryconvention
Use the foreign key relationship and the <primarykeyproperty> mode as the attribute appearance.
• Propertymaxlengthconvention
Configure all the string and byte [] attributes, with the maximum length by default.
• Storegeneratedidentitykeyconvention
By default, the primary keys of All integers are identified.
• Typenameforeignkeydiscoveryconvention
Use the <principaltypename> <primarykeyproperty> mode as the appearance of the property.
*/
}