我试图克隆一个名为 IdentitySample 的项目,但我想将其重命名为 RecreationalServicesTicketingSystem。我已经遵循了一些关于如何重命名所有内容的指南,但应用程序似乎仍在运行
IdentitySample.Controllers.HomeController 。我尝试使用查找功能查看代码以查看 IdentitySample 是否仍在我们的应用程序中,但我没有找到。
也可以给我一些我可能错过重命名解决方案的地方吗?
Multiple types were found that match the controller named 'Home'. This can happen if the route that services this request ('{controller}/{action}/{id}') does not specify namespaces to search for a controller that matches the request. If this is the case, register this route by calling an overload of the 'MapRoute' method that takes a 'namespaces' parameter.
The request for 'Home' has found the following matching controllers: RecreationalServicesTicketingSystem.Controllers.HomeController IdentitySample.Controllers.HomeController
HomeController.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Threading.Tasks;
using System.Net;
using System.Web;
using System.Web.Mvc;
using RecreationalServicesTicketingSystem.Models;
namespace RecreationalServicesTicketingSystem.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
[Authorize]
public ActionResult About()
{
ViewBag.Message = "Your app description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
}
}
View\Home\Index.cshtml
@{
ViewBag.Title = "Home Page";
}
<div class="jumbotron">
<h1>ASP.NET Identity</h1>
<p class="lead">ASP.NET Identity is the membership system for ASP.NET apps. Following are the features of ASP.NET Identity in this sample application.</p>
<p><a href="http://www.asp.net/identity" class="btn btn-primary btn-large">Learn more »</a></p>
</div>
<div class="row">
<div class="col-md-4">
<dl>
<dt>Initialize ASP.NET Identity</dt>
<dd>
You can initialize ASP.NET Identity when the application starts. Since ASP.NET Identity is Entity Framework based in this sample,
you can create DatabaseInitializer which is configured to get called each time the app starts.
<strong>Please look in App_Start\IdentityConfig.cs</strong>
This code shows the following
<ul>
<li>When should the Initializer run and when should the database be created</li>
<li>Create Admin user</li>
<li>Create Admin role</li>
<li>Add Admin user to Admin role</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Add profile data for the user</dt>
<dd>
<a href="http://blogs.msdn.com/b/webdev/archive/2013/10/16/customizing-profile-information-in-asp-net-identity-in-vs-2013-templates.aspx">Please follow this tutorial.</a>
<ul>
<li>Add profile information in the Users Table</li>
<li>Look in Models\IdentityModels.cs for examples</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Validation</dt>
<dd>
When you create a User using a username or password, the Identity system performs validation on the username and password, and the passwords are hashed before they are
stored in the database. You can customize the validation by changing some of the properties of the validators such as Turn alphanumeric on/off, set minimum password length
or you can write your own custom validators and register them with the UserManager.
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Register a user and login</dt>
<dd>
Click @Html.ActionLink("Register", "Register", "Account") and see the code in AccountController.cs and Register Action.
Click @Html.ActionLink("Log in", "Login", "Account") and see the code in AccountController.cs and Login Action.
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Social Logins</dt>
<dd>
You can the support so that users can login using their Facebook, Google, Twitter, Microsoft Account and more.
</dd>
<dd>
<ul>
<li>
<a href="http://www.windowsazure.com/en-us/documentation/articles/web-sites-dotnet-deploy-aspnet-mvc-app-membership-oauth-sql-database/">Add Social Logins</a>
</li>
<li>
<a href="http://blogs.msdn.com/b/webdev/archive/2013/10/16/get-more-information-from-social-providers-used-in-the-vs-2013-project-templates.aspx">Get more data about the user when they login suing Facebook</a>
</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Basic User Management</dt>
<dd>
Do Create, Update, List and Delete Users.
Assign a Role to a User.
Only Users In Role Admin can access this page. This uses the [Authorize(Roles = "Admin")] on the UserAdmin controller.
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Basic Role Management</dt>
<dd>
Do Create, Update, List and Delete Roles.
Only Users In Role Admin can access this page. This authorization is doen by using the [Authorize(Roles = "Admin")] on the RolesAdmin controller.
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Account Confirmation</dt>
<dd>
When you register a new account, you will be sent an email confirmation.
You can use an email service such as <a href="http://www.windowsazure.com/en-us/documentation/articles/sendgrid-dotnet-how-to-send-email/">SendGrid</a> which integrate nicely with Windows Azure and requires no configuration or
set up an SMTP server to send email.
You can send email using the EmailService which is registered in App_Start\IdentityConfig.cs
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Two-Factor Authentication</dt>
<dd>
This sample shows how you can use Two-Factor authentication. This sample has a SMS and email service registered where you can send SMS or email for sending the security code.
You can add more two-factor authentication factors such as QR codes and plug them into ASP.NET Identity.
<ul>
<li>
You can use a SMS using <a href="https://www.twilio.com/">Twilio</a> or use any means of sending SMS. Please <a href="https://www.twilio.com/docs/quickstart/csharp/sms/sending-via-rest">read</a> for more details on using Twilio.
You can send SMS using the SmsService which is registered in App_Start\IdentityConfig.cs
</li>
<li>
You can use an email service such as <a href="http://www.windowsazure.com/en-us/documentation/articles/sendgrid-dotnet-how-to-send-email/">SendGrid</a> or
set up an SMTP server to send email.
You can send email using the EmailService which is registered in App_Start\IdentityConfig.cs
</li>
<li>
When you login, you can add a phone number by clicking the Manage page.
</li>
<li>
Once you add a phone number and have the Phone service hooked to send a SMS, you will get a code through SMS to confirm your phone number.
</li>
<li>
In the Manage page, you can turn on Two-Factor authentication.
</li>
<li>
When you logout and login, after you enter the username and password, you will get an option of how to get the security code to use for two-factor authentication.
</li>
<li>
You can copy the code from your SMS or email and enter in the form to login.
</li>
<li>
The sample also shows how to protect against Brute force attacks against two-factor codes. When you enter a code incorrectly for 5 times then you will be
lockedout for 5 min before you can enter a new code. These settings can be configured in App_Start\IdentityConfig.cs by setting DefaultAccountLockoutTimeSpan and MaxFailedAccessAttemptsBeforeLockout on the UserManager.
</li>
<li>
If the machine you are browsing this website is your own machine, you can choose to check the "Remember Me" option after you enter the code.
This option will remember you forever on this machine and will not ask you for the two-factor authentication, the next time when you login to the website.
You can change your "Remember Me" settings for two-factor authentication in the Manage page.
</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Account Lockout</dt>
<dd>
Provide a way to Lockout out the user if the user enters their password or two-factor codes incorrectly.
The number of invalid attempts and the timespan for the users are locked out can be configured.
A developer can optionally turn off Account Lockout for certain user accounts should they need to.
</dd>
<ul>
<li>Account LockOut settings can be configured in the UserManager in IdentityConfig.cs</li>
</ul>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Security Token provider</dt>
<dd>
Support a way to regenerate the Security Token for the user in cases when the User changes there password or any other security related information such as removing an associated login(such as Facebook, Google, Microsoft Account etc).
This is needed to ensure that any tokens generated with the old password are invalidated. In the sample project, if you change the users password then a new token is generated for the user and any previous tokens are invalidated.
This feature provides an extra layer of security to your application since when you change your password, you will be logged out from everywhere (all other browsers) where you have logged into this application.
</dd>
<dd>
<ul>
<li>The provider is registered when you add CookieAuthentication in StartupAuth to your application.</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Password Reset</dt>
<dd>
Allows the user to reset their passwords if they have forgotten their password. In this sample users need to confirm their email before they can reset their passwords.
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Custom Storage providers</dt>
<dd>
You can extend ASP.NET Identity to write your own custom storage provider for storing the ASP.NET Identity system and user data
in a persistance system of your choice such as MondoDb, RavenDb, Azure Table Storage etc.
</dd>
<dd>
<ul>
<li>
<a href="http://www.asp.net/identity/overview/extensibility/overview-of-custom-storage-providers-for-aspnet-identity">
learn more on how to implement your own storage provider
</a>
</li>
</ul>
</dd>
</dl>
</div>
<div class="col-md-4">
<dl>
<dt>Documentation</dt>
<dd>
<ul>
<li>
Tutorials: <a href="www.asp.net/identity">www.asp.net/identity</a>
</li>
<li>
StackOverflow: <a href="http://stackoverflow.com/questions/tagged/asp.net-identity">http://stackoverflow.com/questions/tagged/asp.net-identity</a>
</li>
<li>
Twitter: #identity #aspnet
</li>
<li>
<a href="http://curah.microsoft.com/55636/aspnet-identity">ASP.NET Identity on curah</a>
</li>
<li>
Have bugs or suggestions for ASP.NET Identity <a href="http://aspnetidentity.codeplex.com/">http://aspnetidentity.codeplex.com/</a>
</li>
</ul>
</dd>
</dl>
</div>
</div>
最佳答案
基本上您有多个名为 HomeController 的 Controller ,错误是给出了答案。我假设您没有删除原始的 IdentitySample.Controllers.HomeController。
您有 2 个选择。
IdentitySample.Controllers.HomeController 实例。如果您想使用选项 #2,那么在您的路由表中将默认路由从
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
);
到
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "RecreationalServicesTicketingSystem.Controllers" }
);
在 App_Start\RouteConfig.cs 中
第二个示例告诉我们在 "RecreationalServicesTicketingSystem.Controllers" 命名空间中寻找 Controller 。
关于c# - MVC5 发现多个类型与名为 'Home' 的 Controller 匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36274260/
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
Rails2.3可以选择随时使用RouteSet#add_configuration_file添加更多路由。是否可以在Rails3项目中做同样的事情? 最佳答案 在config/application.rb中:config.paths.config.routes在Rails3.2(也可能是Rails3.1)中,使用:config.paths["config/routes"] 关于ruby-on-rails-Rails3中的多个路由文件,我们在StackOverflow上找到一个类似的问题
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
我有多个ActiveRecord子类Item的实例数组,我需要根据最早的事件循环打印。在这种情况下,我需要打印付款和维护日期,如下所示:ItemAmaintenancerequiredin5daysItemBpaymentrequiredin6daysItemApaymentrequiredin7daysItemBmaintenancerequiredin8days我目前有两个查询,用于查找maintenance和payment项目(非排他性查询),并输出如下内容:paymentrequiredin...maintenancerequiredin...有什么方法可以改善上述(丑陋的)代
我需要从一个View访问多个模型。以前,我的links_controller仅用于提供以不同方式排序的链接资源。现在我想包括一个部分(我假设)显示按分数排序的顶级用户(@users=User.all.sort_by(&:score))我知道我可以将此代码插入每个链接操作并从View访问它,但这似乎不是“ruby方式”,我将需要在不久的将来访问更多模型。这可能会变得很脏,是否有针对这种情况的任何技术?注意事项:我认为我的应用程序正朝着单一格式和动态页面内容的方向发展,本质上是一个典型的网络应用程序。我知道before_filter但考虑到我希望应用程序进入的方向,这似乎很麻烦。最终从任何
我想要做的是有2个不同的Controller,client和test_client。客户端Controller已经构建,我想创建一个test_clientController,我可以使用它来玩弄客户端的UI并根据需要进行调整。我主要是想绕过我在客户端中内置的验证及其对加载数据的管理Controller的依赖。所以我希望test_clientController加载示例数据集,然后呈现客户端Controller的索引View,以便我可以调整客户端UI。就是这样。我在test_clients索引方法中试过这个:classTestClientdefindexrender:template=>
我在我的项目中添加了一个系统来重置用户密码并通过电子邮件将密码发送给他,以防他忘记密码。昨天它运行良好(当我实现它时)。当我今天尝试启动服务器时,出现以下错误。=>BootingWEBrick=>Rails3.2.1applicationstartingindevelopmentonhttp://0.0.0.0:3000=>Callwith-dtodetach=>Ctrl-CtoshutdownserverExiting/Users/vinayshenoy/.rvm/gems/ruby-1.9.3-p0/gems/actionmailer-3.2.1/lib/action_mailer
在MRIRuby中我可以这样做:deftransferinternal_server=self.init_serverpid=forkdointernal_server.runend#Maketheserverprocessrunindependently.Process.detach(pid)internal_client=self.init_client#Dootherstuffwithconnectingtointernal_server...internal_client.post('somedata')ensure#KillserverProcess.kill('KILL',
在我的应用程序中,我需要能够找到所有数字子字符串,然后扫描每个子字符串,找到第一个匹配范围(例如5到15之间)的子字符串,并将该实例替换为另一个字符串“X”。我的测试字符串s="1foo100bar10gee1"我的初始模式是1个或多个数字的任何字符串,例如,re=Regexp.new(/\d+/)matches=s.scan(re)给出["1","100","10","1"]如果我想用“X”替换第N个匹配项,并且只替换第N个匹配项,我该怎么做?例如,如果我想替换第三个匹配项“10”(匹配项[2]),我不能只说s[matches[2]]="X"因为它做了两次替换“1fooX0barXg
刚入门rails,开始慢慢理解。有人可以解释或给我一些关于在application_controller中编码的好处或时间和原因的想法吗?有哪些用例。您如何为Rails应用程序使用应用程序Controller?我不想在那里放太多代码,因为据我了解,每个请求都会调用此Controller。这是真的? 最佳答案 ApplicationController实际上是您应用程序中的每个其他Controller都将从中继承的类(尽管这不是强制性的)。我同意不要用太多代码弄乱它并保持干净整洁的态度,尽管在某些情况下ApplicationContr