我有这个简单的锚标签。
<a asp-area="Admin" asp-action="Create" asp-controller="Users" class="btn btn-default">Create</a>
Run Code Online (Sandbox Code Playgroud)
代码结构如下。
生成的标记如下
<a class="btn btn-default" href="/Admin/Users">Create</a>
Run Code Online (Sandbox Code Playgroud)
它缺少操作(创建),但其余标签似乎工作正常。
路由设置如下
app.UseMvc(
routes =>
{
routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
routes.MapRoute(
name: "areaRoute",
template: "{area:exists}/controller=Admin/{action=Index}/{id?}");
});
Run Code Online (Sandbox Code Playgroud) 我试图使用这样的代码调用web api端点.
verifyUserLogin(userName: string, password: string): Observable<UserSession>
{
let observable = this._http.get(this.baseUrl + "?userName=" + encodeURIComponent(userName) + "&password=" + encodeURIComponent(password));
return observable
.map(this.convertResponseToUserSession)
.do(data => this.logData(data))
.catch(this.handleError);
}
Run Code Online (Sandbox Code Playgroud)
地图调用中的转换函数如下.
private convertResponseToUserSession (res: Response)
{
let body = res.json();
return body.data || { };
}
Run Code Online (Sandbox Code Playgroud)
使用fiddler我得到以下RAW响应.
HTTP/1.1 200 OK
Cache-Control: no-cache
Pragma: no-cache
Content-Type: application/json; charset=utf-8
Expires: -1
Server: Microsoft-IIS/10.0
X-AspNet-Version: 4.0.30319
X-SourceFiles: =?UTF-8?B?RDpcUHJvamVjdHNcU05DQ2xpZW50c1xTTkNDbGllbnRzXGFwaVxVc2Vy?=
X-Powered-By: ASP.NET
Date: Tue, 09 May 2017 17:49:52 GMT
Content-Length: 465
{"id":"c384bf34-6bbc-45a9-944f-6d2d4f7874af","lastAccess":"2017-05-09T14:18:39.7111621-04:00","userId":"arsalan","displayName":"Arsalan","emailAddress":"Arsalan@mycompany.com","employeeId":"3123123","compnayAddressNumber":123123,"departmentAddressNumber":123123,"homeDepartmentAddressNumber":123123,"lineId":0,"phoneNumber":"123-456-7890","companyName":"My Corporation","homeDepartment":"Information Technology","managerName":"My Manager"}
Run Code Online (Sandbox Code Playgroud)
对于班级
export …Run Code Online (Sandbox Code Playgroud)