C# WCF接管控制器/操作URL创建?
我已经创建了一个MVC5站点,它还托管了一个WCF API。使用其他博客建议,我创建了以下路线:C# WCF接管控制器/操作URL创建?,c#,asp.net-mvc,wcf,C#,Asp.net Mvc,Wcf,我已经创建了一个MVC5站点,它还托管了一个WCF API。使用其他博客建议,我创建了以下路线: routes.Add(new ServiceRoute("AuthZ", new ServiceHostFactory(), typeof(AuthZ))); routes.MapRoute( name: "Default", url: "{controller}/{action}", defaults: new { controller = "Home", action
routes.Add(new ServiceRoute("AuthZ", new ServiceHostFactory(), typeof(AuthZ)));
routes.MapRoute(
name: "Default",
url: "{controller}/{action}",
defaults: new { controller = "Home", action = "Index" }
);
因此,在我的表单/视图中,现在我有以下代码:
@using (Html.BeginForm("Authenticate", "Login"))
{
....
但不是指向/Login/Authenticate
的表单,它实际上是这样的:
<form action="/AuthZ?action=Authenticate&controller=Login" method="post">
...
这取决于生成表单/视图的上下文。如果您当前正在请求/AuthZ。。。那么这就是目前的主要路线。尝试使用指定控制器名称alsono,调用的页面/上下文为/login。
BeginForm
中的重载是使用控制器名称(Login)的重载,我尝试了使用和不使用它。
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="AuthZBindingConfiguration">
<security mode="None" />
</binding>
</wsHttpBinding>
</bindings>
<services>
<service behaviorConfiguration="MetadataBehavior" name="soap.AuthZ">
<endpoint address="/AuthZ" binding="wsHttpBinding" bindingConfiguration="AuthZBindingConfiguration" name="MainWSBinding" contract="soap.IAuthZ" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="MetadataBehavior">
<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
</system.serviceModel>