Asp.net tag helpers not worked in my project.
I add this code to project.json
"Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
"Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
in _ViewImports.cshtml
i add
@using Homebank
@addTagHelper "*, Microsoft.AspNet.Mvc.TagHelpers"
When in view i use asp.net tag helpers - page not return data;
@model Homebank.Models.Admins
@{
ViewData["Title"] = "Create";
}
<input asp-for="Email" class="form-control" />
Your tag helper is trying to access Homebank.Models.Admins.Email
. Make sure that class has an Email
property.
namespace Homebank.Models
{
public class Admins
{
public string Email { get; set; }
}
}
I think that is the most likely fix, because your code works when you remove the Email
tag helper. Here are some other ideas, though.
Instead of a white screen, we can receive a detailed error page. Add the following line of code to the Configure
method.
public void Configure(IApplicationBuilder app)
{
// other code omitted for clarity
app.UseDeveloperExceptionPage();
app.UseMvc();
}
That will provide more debugging information. Eg
It might be that you need to restore the Microsoft.AspNet.Mvc.TagHelpers
package. Here is how from the command line:
dnu restore
dnu build
dnx web
This is an unlikely fix, because your code runs when you comment out the Email
tag helper, even though you're using tag helpers in the _ViewImports.cshtml
page.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.