小编fib*_*ics的帖子

发现多个类型与名为"Home"的控制器匹配 - 在两个不同的区域中

我的项目有两个方面.现在,当我运行程序时,我收到此错误:

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:
BaseAdminMVC.Areas.BaseAdmin.Controllers.HomeController
BaseAdminMVC.Areas.TitomsAdmin.Controllers.HomeController  
Run Code Online (Sandbox Code Playgroud)

我在这里找到了一些来源:多个控制器名称
但我认为它只适用于一个区域.
就我而言,我在不同领域有两个项目.希望有人能告诉我该怎么做才能解决问题.
这是Global.asax文件:

public static void RegisterRoutes(RouteCollection routes) …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc asp.net-mvc-routing asp.net-mvc-3

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

CloudBlob.DownloadToStream返回null

我正在尝试通过流从cloudBlob下载文件.我参考这篇文章CloudBlob

这是下载blob的代码

public Stream DownloadBlobAsStream(CloudStorageAccount account, string blobUri)
{
    Stream mem = new MemoryStream();
    CloudBlobClient blobclient = account.CreateCloudBlobClient();
    CloudBlockBlob blob = blobclient.GetBlockBlobReference(blobUri);

    if (blob != null)
        blob.DownloadToStream(mem);

    return mem;
}  
Run Code Online (Sandbox Code Playgroud)

并将代码转换为字节数组

    public static byte[] ReadFully(Stream input)
    {
        byte[] buffer = new byte[16 * 1024];
        using (MemoryStream ms = new MemoryStream())
        {
            int read;
            while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
            {
                ms.Write(buffer, 0, read);
            }
            return ms.ToArray();
        }
    }  
Run Code Online (Sandbox Code Playgroud)

但我总是得到零价值.以下是流式文件的内容.

在此输入图像描述

这有什么问题?请帮忙.

编辑

ReadFully不允许在Position 方法中将Position设置为0 ,所以我把它放在里面DownloadBlobAsStream

这应该现在有效: …

c# cloud blob azure azure-storage

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

无法将字符串解析为整数值

我真的不知道为什么我会对此有所了解0:

在此输入图像描述

但是这段代码效果很好:

int val = Convert.ToInt32("1546");    
Run Code Online (Sandbox Code Playgroud)

这是appsetting:

<add key="PesoPayMerchantId" value="?1546"/>
Run Code Online (Sandbox Code Playgroud)

任何的想法?

EDIT1

我想得到整数值"1546",但它无法正常工作.
以下是获取appsetting的代码:

    public static string GetConfigurationString(string appSettingValue)
    {
        return ConfigurationManager.AppSettings[appSettingValue];
    }  
Run Code Online (Sandbox Code Playgroud)

我已经尝试了你的建议,这就是结果:

在此输入图像描述
在此输入图像描述
在此输入图像描述

字符串值是正确的("1546"),但不能解析为整数.这里发生了什么?

编辑2

我非常肯定价值:

<add key="PesoPayMerchantId" value="?1546"/>  
Run Code Online (Sandbox Code Playgroud)

实际上是数字的组合"1546"
但是当我尝试使用Immediate Window它重新编写字符串值时,现在可以解析它.但我仍然无法弄清楚这个的原因是Bug什么?

在此输入图像描述

编辑3

最后,感谢Johnny,它现在有效

我做的是,我重写了整个,<add key="PesoPayMerchantId" value="1546"/>现在可以解析了.感谢你的帮助.:d

c# string integer appsettings

10
推荐指数
1
解决办法
1591
查看次数

构建linq查询以获得最快性能的正确方法?

这里也提出了类似的问题,但没有一个符合我的需要.
我做了测试用例,看看哪个更快.但我觉得我的linq代码仍然很慢.如何构建linq代码以获得更快的性能?

其他人说使用double .Tolist()会导致操作变慢,当我测试它时,它表明它比任何其他测试都快.

测试:

Preparation
---------------------------------------------------------------
return Properties of UserInfo(userinf, true){
    UserID = userinf.UserID;
    FirstName = userinf.user.FirstName;
    MiddleName = userinf.user.MiddleName;
    LastName = userinf.user.LastName;
    LoginID = userinf.user.LoginID;
    Birthday = userinf.Birthday;
}

skip = 0;
take = 100;

total table records = 304;

Linq to Entity Framework 
Run Code Online (Sandbox Code Playgroud)

提琴手:v2.4.0.0

https://127.0.0.1/..../RetrieveUserInfo?skip=0&take=100
{
    "client":{
        "SessionID":"5433ab64-7e0d-444f-b886-a901ea9a0601"
    },
    "session":{
        "SessionID":"35b75daa-25ad-45a4-9f99-0e69ec3b66a4"
    }
}
Run Code Online (Sandbox Code Playgroud)
//Test 1
//1) 00:00:15.3068755 -- Attempt1
//2) 00:00:13.8207905 -- Attempt2
//3) 00:00:16.2489294 -- Attempt3

var list = (from usr in dbase.userinfoes
            select usr).OrderBy(i …
Run Code Online (Sandbox Code Playgroud)

c# linq entity-framework generic-list

9
推荐指数
1
解决办法
6312
查看次数

WARN [web-server]:404:/views/nav/offline.html

任何人都知道如何解决/删除这个非常烦人的警告?

Running "karma:unit" (karma) task
INFO [karma]: Karma v0.12.23 server started at http://localhost:8080/
INFO [launcher]: Starting browser PhantomJS
INFO [PhantomJS 1.9.7 (Windows 7)]: Connected on socket rrNTMtmcd322dIl7A9fa with id 95590782
WARN [web-server]: 404: /views/nav/offline.html
WARN [web-server]: 404: /views/scan/scan.qr.html  
Run Code Online (Sandbox Code Playgroud)

karma.conf.js

// Karma configuration
// http://karma-runner.github.io/0.12/config/configuration-file.html
// Generated on 2014-08-26 using
// generator-karma 0.8.3

module.exports = function (config) {
    'use strict';

    config.set({
        // enable / disable watching file and executing tests whenever any file changes
        autoWatch: true,

        // base path, that will …
Run Code Online (Sandbox Code Playgroud)

angularjs gruntjs karma-runner

8
推荐指数
1
解决办法
4594
查看次数

在angularjs中重定向状态

这是状态配置:

angular
    .module('grabhutApp', [...])
    .config(function ($stateProvider, $urlRouterProvider) {

        $stateProvider
            // ACCOUNT
            .state('account', {
                abstract: true,
                url: '/account',
                templateUrl: 'index.html'
            })
            .state('account.main', {
                url: '',
                templateUrl: 'views/account/account.login.html',
                controller: 'AccountController'
            })
            .
            .
            .
            // NO VIEWS
            .state('nv', {
                abstract: true,
                url: '/nv'
            })
            .state('nv.logout', {
                url: '/logout'
            })  
    });
Run Code Online (Sandbox Code Playgroud)

nv和其子状态不会有任何物理视图或控制器.
我希望它们作为调用某些功能的链接.

调用注销方法的服务:

angular.module('grabhutApp')
    .factory('$grabhutAccountService', function ($state, $grabhutDataService) {

        var methods = {     
            .
            .
            logoutUser: function () {
                $grabhutDataService.user.removeSession();
                $state.go('account.main', {}, {location: 'replace'});
            }
            .
            .
        };

        return methods; …
Run Code Online (Sandbox Code Playgroud)

state angularjs angular-ui-router rootscope ionic-framework

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

如何处理WebFaultException以返回CustomException?

我做了我的自定义异常,每次发生错误时都会抛出try-catch:

[Serializable]
public class CustomException : Exception
{
    public CustomException() { }

    public CustomException(string message)
        : base(message) { }

    public CustomException(string message, Exception innerException)
        : base(message, innerException) { }
}  
Run Code Online (Sandbox Code Playgroud)

我有两个服务,REST和SOAP.对于SOAP服务,我在抛出自定义异常时没有任何问题.但是在REST中,我遇到了很多困难.

以下是抛出WebFaultException的方法:

    public static WebFaultException RestGetFault(ServiceFaultTypes fault)
    {
        ServiceFault serviceFault = new ServiceFault();
        serviceFault.Code = (int)fault;
        serviceFault.Description = ConfigAndResourceComponent.GetResourceString(fault.ToString());
        FaultCode faultCode = new FaultCode(fault.ToString());
        FaultReasonText faultReasonText = new FaultReasonText(serviceFault.Description);
        FaultReason faultReason = new FaultReason(faultReasonText);
        WebFaultException<ServiceFault> webfaultException = new WebFaultException<ServiceFault>(serviceFault, HttpStatusCode.InternalServerError);

        throw webfaultException;
    }  
Run Code Online (Sandbox Code Playgroud)

ServiceFault是一个类,它有一些属性,我用它来提供我需要的所有信息.

我使用此方法在REST服务中引发异常:

    public static CustomException GetFault(ServiceFaultTypes fault) …
Run Code Online (Sandbox Code Playgroud)

c# rest asp.net-mvc

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

将字符串转换为正确的URI格式?

有没有简单的方法将电子邮件地址字符串转换为正确的URI格式?

输入:

http://mywebsite.com/validate_email/3DE4ED727750215D957F8A1E4B117C38E7250C33/myemail@yahoo.com  
Run Code Online (Sandbox Code Playgroud)

输出应该是:

http://mywebsite.com/validate_email/3DE4ED727750215D957F8A1E4B117C38E7250C33/myemail%40yahoo.com  
Run Code Online (Sandbox Code Playgroud)

如果我没有输出,我得到一个错误响应,如

An Error Was Encountered
The URI you submitted has disallowed characters.
Run Code Online (Sandbox Code Playgroud)

提前致谢 !

html c# asp.net

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

如何以JSON格式传递TimeSpan值?

我用Fiddler来测试我的WCF Rest.我总是得到

HTTP/1.1 400 Bad Request  
Run Code Online (Sandbox Code Playgroud)

有这个帖子值:

{
    "session":{
        "Session":"088a688d-ea69-4264-9266-381e9e540d00",
        "LoginID":"testid",
        "Serial":"testserial"
    },
    "sub":[
        {
            "Type":0,
            "StartDate":"\/Date(1319731200000+0800)\/",
            "EndDate":"\/Date(1319731200000+0800)\/",
            "Duration":"12:12:12"
        }
    ]
}  
Run Code Online (Sandbox Code Playgroud)

我在'持续时间'值中得到错误.我一直在网上搜索但没有运气.
我希望我能在这里找到答案.非常感谢!

c# wcf json

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

使用WCF Rest服务下载文件?

如果有一种方法上传文件使用休息通过流将有" Download"?如果有,你能告诉我怎么样?提前致谢!

c# rest wcf

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