小编Tyk*_*ikk的帖子

MVC5发现多个类型匹配名为'Home'的控制器

我试图克隆一个名为IdentitySample的项目,但我想将其重命名为RecreationalServicesTicketingSystem.我已经按照一些指南来了解如何重命名所有内容,但似乎应用程序仍在继续 IdentitySample.Controllers.HomeController.我已经尝试使用find函数查看代码以查看IdentitySample是否仍在我们的应用程序中,但我没有找到.

可以给我一些指示,我可能错过了重命名解决方案?

找到了多个匹配名为"Home"的控制器的类型.如果为此请求提供服务的路由('{controller}/{action}/{id}')未指定名称空间来搜索与请求匹配的控制器,则会发生这种情况.如果是这种情况,请通过调用带有'namespaces'参数的'MapRoute'方法的重载来注册此路由.

对'Home'的请求找到了以下匹配的控制器: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();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

查看\首页\ Index.cshtml

@{
    ViewBag.Title = "Home Page";
} …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc entity-framework asp.net-identity

13
推荐指数
2
解决办法
2万
查看次数

'Compare'是'System.ComponentModel.DataAnnotations.CompareAttribute'和'System.Web.Mvc.CompareAttribute'之间的模糊引用.

我的AccountController中有这个错误.

找不到类型或命名空间名称'SelectListItem'(您是否缺少using指令或程序集引用?

显而易见的解决方法是添加using System.Web.Mvc;但是当我这样做时,我会得到4个新错误

在两个不同的行:

找不到类型或命名空间名称'ErrorMessage'(您是否缺少using指令或程序集引用?)

在另外两个不同的行:

'Compare'是'System.ComponentModel.DataAnnotations.CompareAttribute'和'System.Web.Mvc.CompareAttribute'之间的模糊引用.

为什么会发生这种情况,我该如何解决?

public class RegisterViewModel
    {
[DataType(DataType.Password)]
        [Display(Name = "Confirm password")]
        [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]
        public string ConfirmPassword { get; set; }
       public IEnumerable<SelectListItem> DepotList { get; set; }


}
Run Code Online (Sandbox Code Playgroud)

ResetPasswordViewModel

public class ResetPasswordViewModel
{

    [DataType(DataType.Password)]
    [Display(Name = "Confirm password")]
    [Compare("Password", ErrorMessage = "The password and confirmation password do not match.")]

}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc entity-framework asp.net-identity

11
推荐指数
1
解决办法
5933
查看次数

PagedList MVC不包含PagedListPager的定义

我不知道为什么PageCount,PageNumber和PageListPager不包含定义或无法找到.它问我是否缺少using指令或汇编引用,但我在我的用户控制器中有它.

Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
 to 
@Html.PagedListPager( Model, page => Url.Action("Index", new { page, sortOrder = ViewBag.CurrentSort, currentFilter=ViewBag.CurrentFilter }) )
Run Code Online (Sandbox Code Playgroud)

注意:以下图像和代码仅供参考

数据库错误

Visual Studio错误

控制器\ UserController.cs

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using RecreationalServicesTicketingSystem.Models;
using RecreationalServicesTicketingSystem.DAL;
using PagedList;

namespace RecreationalServicesTicketingSystem.Controllers
{
    public class UserController : Controller
    {
        private IssueContext db = new IssueContext();

        //
        // GET: /User/

        public ViewResult Index(string sortOrder, string currentFilter, string searchString, int? page)
        {
            ViewBag.CurrentSort …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc nuget-package asp.net-mvc-4

7
推荐指数
1
解决办法
1万
查看次数

Swift图像处理

我是新手Swift,我正在尝试创建一个类/结构过滤器,它在构造函数中采用过滤器公式和强度.该类有一种方法,可以在给定参数的图像中应用给定强度的给定公式,然后返回修改后的图像.

我们有一个叫做类的RGBAImage.swift方法,它有将方法转换UIImage成RGBAImage,反之亦然.

这是我创建的类:

import UIKit


let image = UIImage(named: "sample")!






class imageFilter{


    func increaseContrast(image: UIImage) -> UIImage{
        let rgbaImage = RGBAImage(image: image)!
        var totalRed = 0
        var totalGreen = 0
        var totalBlue = 0
        let pixelCount = rgbaImage.width * rgbaImage.height

        for y in 0..<rgbaImage.height {
            for x in 0..<rgbaImage.width {
                let index = y * rgbaImage.width + x
                let pixel = rgbaImage.pixels[index]
                totalRed += Int(pixel.red)
                totalGreen += Int(pixel.green)
                totalBlue += Int(pixel.blue)
            }
        }


        let …
Run Code Online (Sandbox Code Playgroud)

image-processing ios swift

6
推荐指数
1
解决办法
4246
查看次数

一个或多个实体的MVC5验证失败.有关详细信息,请参阅"EntityValidationErrors"属性

我似乎无法使用我的种子方法获取update-database来填充我的数据库.

我正在使用EF应用程序编写MVC4,现在正在使用EF将其升级到MVC5.以前在MVC4中我必须创建一个名为User.cs的类,但在使用Identity的MVC5中,我们需要从IdentityUser派生User类.

我正在使用与MVC4配置文件完全相同的代码,只是更改了:

var users = new List<User>
Run Code Online (Sandbox Code Playgroud)

var users = new List<ApplicationUser>
Run Code Online (Sandbox Code Playgroud)

new User{ FirstMi....
Run Code Online (Sandbox Code Playgroud)

new ApplicationUser { FirstMi....
Run Code Online (Sandbox Code Playgroud)

错误在第61行,就在这里

users.ForEach(s => context.Users.AddOrUpdate(p => p.FirstMidName,s)); context.SaveChanges()

PM> Update-Database 
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
No pending explicit migrations.
Running Seed method.
System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
   at System.Data.Entity.Internal.InternalContext.SaveChanges()
   at System.Data.Entity.Internal.LazyInternalContext.SaveChanges()
   at System.Data.Entity.DbContext.SaveChanges()
   at RecreationalServicesTicketingSystem.Migrations.Configuration.Seed(ApplicationDbContext context) in C:\Users\Jason\Documents\Visual Studio …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc entity-framework asp.net-identity

3
推荐指数
2
解决办法
2万
查看次数

Android Intent createChooser()

我的目标是创建一个隐式意图并使用 Intent.createChooser() 方法来选择一个应用程序来查看网页我被告知我需要创建一个选择器意图,以选择将执行的活动。

我的第一个问题是为什么我需要 2 个意图?为什么我不能只使用 baseIntent 并将其放入 createChooser() 方法中?

我的第二个问题是为什么我的应用程序没有显示可以选择哪个应用程序打开我的 URL 的菜单?

有人也可以检查我的意图过滤器,看看我是否得到了它们。

主活动.java

static private final String URL = "http://www.google.com";
static private final String TAG = "Lab-Intents";

// For use with app chooser
static private final String CHOOSER_TEXT = "Load " + URL + " with:";



private void startImplicitActivation() {


Log.i(TAG, "Entered startImplicitActivation()");

Uri webpage = Uri.parse(URL);
Intent baseIntent = new Intent(Intent.ACTION_VIEW,webpage);

Intent chooserIntent = null;


startActivity(Intent.createChooser(baseIntent,CHOOSER_TEXT));
Run Code Online (Sandbox Code Playgroud)

}

AndroidManifest.xml

   <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.DEFAULT"></category>
        <category android:name="android.intent.category.BROWSABLE"></category>
        <action …
Run Code Online (Sandbox Code Playgroud)

android android-intent

2
推荐指数
1
解决办法
2123
查看次数