小编Mat*_*cic的帖子

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

使用.gitignore进行App.config或Web.config中的连接字符串的最佳做法

*.gitignore在为一个更大的团队工作时,我尝试了几种管理连接字符串的方法.

gitignore的官方.gitignore文件库中,我下载了VisualStudio.gitignore,并将其作为所有项目的起点.

访问http://gitignore.io/,键入VisualStudio,然后下载文件即可完成相同的过程.

在此输入图像描述

我目前使用的方法是利用SectionInformation.ConfigSource属性

<connectionStrings configSource="myConnectionStrings.config" />
Run Code Online (Sandbox Code Playgroud)

然后加入myConnectionStrings.config.gitignore,因为它不添加整个这是很好的*.config.

您也可以在另一个项目(MyProject.Data层)中使用相同的myConnectionStrings.config

<configuration>
  <connectionStrings configSource="myConnectionStrings.config"/>
</configuration>
Run Code Online (Sandbox Code Playgroud)

只记得永远设置复制!

在此输入图像描述

此外,我尝试使用Git中描述的过滤器 - 忽略对配置文件的特定修改,但我发现这是一个过度杀伤力.

我想知道是否有其他方法被认为是最佳做法?

git connection-string visual-studio-2010 gitignore

30
推荐指数
1
解决办法
4147
查看次数

Visual Studio 2013 RTM安装程序失败 - 指定的信任提供程序不支持或知道为主题指定的表单

Visual Studio 2013发布到网络上!

Web开发人员应该了解Visual Studio 2013版本的主要内容

系统要求:

支持的操作系统

Windows 7 SP1(x86和x64)

Windows 8(x86和x64)

Windows 8.1(x86和x64)

Windows Server 2008 R2 SP1(x64)

Windows Server 2012(x64)

Windows Server 2012 R2(x64)

必需的组件

Internet Explorer 10

硬件要求

1.6 GHz或更快的处理器

1 GB RAM(如果在虚拟机上运行,​​则为1.5 GB)

10 GB的可用硬盘空间

5400转硬盘

支持DirectX 9的视频卡,运行速度为1024 x 768或更高

来源:Microsoft Visual Studio Ultimate 2013

我正在尝试在VS 2013 RC之上安装VS 2013 Ultimate,并且以下错误消息阻止了安装.

在此输入图像描述

为主题指定的表单不是指定的信任提供程序支持或已知的表单.

失败的组件是:

Microsoft Visual Studio 2013 VsGraphics助手

Microsoft Visual C++ 2013核心库

Microsoft Visual C++ 2013 x86库

Microsoft Visual C++ 2013 x64库

Microsoft Visual C++ …

installer visual-studio-2013

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

TypeScript是否支持TouchEvent?

UPDATE

TypeScript 1.5.3将HTML Touch事件的声明添加到lib.d.ts

我可以看到它支持UIEvent,但它似乎没有触摸事件的接口.

此代码表示"TouchEvent在当前范围中不存在".

class Touchy {
    private _element:Element;

    constructor(theElement:Element) {
        this._element = theElement;

        theElement.addEventListener("touchstart", (theTouchEvent:TouchEvent) => alert("touchy"));
    }
}
Run Code Online (Sandbox Code Playgroud)

我可以使用UIEvent,但不能使用TouchEvent.我如何使用TypeScript处理TouchEvent?谢谢.

typescript

14
推荐指数
3
解决办法
6426
查看次数

使用媒体类型对ASP.NET Web API 2进行版本控制

我正在使用ASP.NET Web API 2进行属性路由,但我似乎无法使用媒体类型application/vnd.company[.version].param[+json]进行版本控制.

在此输入图像描述

我收到以下错误:

给定的密​​钥不在字典中.

从测试的关键起源_actionParameterNames[descriptor]FindActionMatchRequiredRouteAndQueryParameters()方法.

foreach (var candidate in candidatesFound)
{
        HttpActionDescriptor descriptor = candidate.ActionDescriptor;
        if (IsSubset(_actionParameterNames[descriptor], candidate.CombinedParameterNames))
        {
            matches.Add(candidate);
        }
}
Run Code Online (Sandbox Code Playgroud)

来源:ApiControllerActionSelector.cs

经过进一步调试后,我意识到如果你有两个控制器

[RoutePrefix("api/people")]
public class PeopleController : BaseApiController
{
    [Route("")]
    public HttpResponseMessage GetPeople()
    {
    }

    [Route("identifier/{id}")]
    public HttpResponseMessage GetPersonById()
    {
    }
}

[RoutePrefix("api/people")]
public class PeopleV2Controller : BaseApiController
{     
    [Route("")]
    public HttpResponseMessage GetPeople()
    {
    } 

    [Route("identifier/{id}")]
    public HttpResponseMessage GetPersonById()
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

你不能使用你的自定义,ApiVersioningSelector : DefaultHttpControllerSelector 因为它将测试所有具有相同的控制器的键,如上所述,[RoutePrefix("api/people")]显然会抛出异常. …

c# asp.net-web-api asp.net-web-api-routing

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

获取SignalR中心内的完整URL

我正在开发一个使用SignalR的用户跟踪解决方案,作为学习SignalR的有趣项目,用于ASP.NET MVC应用程序.

目前,我可以跟踪已记录的用户以及他们在特定页面上的时长.如果他们移动到另一个页面,我也跟踪它并且SignalR正在更新的计时器重置...许多其他功能被实现或部分实现.

我面临的问题是如何在SignalR集线器内获得完整的URL控制器/动作/参数?

当我使用HttpContext.Current.Request.Urlurl时总是/ signalr/connect.

注意:

var hub = $.connection.myHub;
$.connection.hub.start();
Run Code Online (Sandbox Code Playgroud)

在_Layout.cshtml中.

更新:

我试过用

var location = '@HttpContext.Current.Request.Url';
var hub = $.connection.myHub;
$.connection.hub.start().done(function () {
    hub.setLocation(location);
});
Run Code Online (Sandbox Code Playgroud)

并且位置正确传递但我不需要在Connect()任务上使用它.是否有可能做到这一点?

更新2:

这种方法不起作用

var hub = $.connection.myHub;
$.connection.hub.start(function(){hub.setLocation(location)});
Run Code Online (Sandbox Code Playgroud)

就像Connect()之前所说的那样.

在我的中心我有几种方法,但我想传递一个值(在我的情况下是一个位置)Connect(),这可能吗?

public class MyHub : Hub, IDisconnect, IConnected
{  
    public Task Connect()
    {
       //do stuff here
       //and i would like to have the **location** value
    } 

    public Task Disconnect()
    {
       //do stuff here            
    }             
} …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc-4 signalr signalr-hub

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

MVC4捆绑GZIP和标头

我正在使用Google PageSpeed和YSlow测试我的网站,而我使用MVC4捆绑包创建的捆绑包没有获得

Gzip(用gzip或deflate压缩资源可以减少通过网络发送的字节数)并且没有

Vary:Accept-Encoding标头(指示代理服务器缓存两个版本的资源:一个压缩,一个未压缩.这有助于避免公共代理无法正确检测到Content-Encoding标头的问题.)

以及如何在ISS上为整个脚本文件夹添加编码头.我知道有HTTP响应标头,然后添加自定义HTTP响应标头,

在此输入图像描述

但是这将在整个脚本文件夹和子文件夹中工作,以及在名称和值字段中放置什么.

怎么能解决这个问题.

问候.

gzip asp.net-mvc-4 asp.net-optimization

9
推荐指数
2
解决办法
8983
查看次数

获取控制器名称

在WebApiConfig.cs中,我有以下内容

public static void Register(HttpConfiguration config)
{

   config.MapHttpAttributeRoutes(); 

   config.Services.Replace(typeof(IHttpControllerSelector),
               new MyApiControllerSelector(config));

   //code omitted for brevity
}
Run Code Online (Sandbox Code Playgroud)

然后在MyApiControllerSelector.cs中我想获得控制器

public override HttpControllerDescriptor SelectController(HttpRequestMessage request)
        {           
            var routeData = request.GetRouteData();           

            var controllerName = (string)routeData.Values["controller"];

            //code omitted for brevity
        }
Run Code Online (Sandbox Code Playgroud)

非常简单,它工作得很好,但现在使用属性路由我认为它需要一个不同的方法? - 因为我似乎无法找到一个简单的方法

我试过了

var controllerName = request.GetActionDescriptor().ControllerDescriptor.ControllerName;
Run Code Online (Sandbox Code Playgroud)

这不起作用.

然后通过调试阅读源代码引导我request.GetRouteData().Values["MS_SubRoutes"]

所以现在我有

string subRoutesKey = "MS_SubRoutes";

var attributedRoutesData = routeData.Values[subRoutesKey] as IEnumerable<IHttpRouteData>; 
var subRouteData = attributedRoutesData.FirstOrDefault();

var actions = (ReflectedHttpActionDescriptor[])subRouteData.Route.DataTokens["actions"];
var controllerName = actions[0].ControllerDescriptor.ControllerName;
Run Code Online (Sandbox Code Playgroud)

哪个有效,但它必须是一个更简单的方法?

UPDATE

@KiranChalla问我的用例是什么,所以我发布了剩下的代码.基本上我正在Accept: …

.net c# asp.net asp.net-mvc asp.net-web-api

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

Chrome Web Driver下载文件

我正在使用Chrome Web Driver 2.10 chromedriver_win32.zipSelenium WebDriver 2.31.2.

启用详细日志记录后,似乎DesiredCapabilities(https://sites.google.com/a/chromium.org/chromedriver/capabilities)正常通过,

[1.174][FINE]:      Initializing session with capabilities {

   "browserName": "chrome",

   "chrome.switches": [  ],

   "chromeOptions": {

      "args": [  ],

      "binary": "",

      "extensions": [  ],

      "prefs": {

         "download.default_directory": "C:\\Downloads",

         "download.directory_upgrade": "true",

         "download.extensions_to_open": "",

         "download.prompt_for_download": "false"

      }

   },

   "javascriptEnabled": true,

   "platform": "WINDOWS",

   "version": ""

}
Run Code Online (Sandbox Code Playgroud)

但Chrome网络驱动程序正在播放*.mp4而不是下载.

我已经尝试过如何使用Selenium Webdriver .NET绑定设置Chrome首选项的解决方案但它似乎不适用于较新的Chrome Web驱动程序版本,如果我尝试使用selenium-dotnet-2.31.2chromedriver_win_26.0.1383.0,它会崩溃.

有人有建议吗?

selenium google-chrome selenium-webdriver chrome-web-driver

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

ASP.NET Web Api作为一个解决方案中的独立项目

如果我想使用WebAPI作为服务连接到不同服务器上的多个数据库并检索我的MVC应用程序将使用的数据,那么最好的方法是什么?

我不希望ApiController与我的MVC项目在同一个项目中,所以我需要添加一个新的WebApi项目(删除所有除了控制器和模板添加的东西都有一个干净的项目)我的MVC应用程序会参考吗?

这是我用来了解WebAPI的教程/博客文章列表:

ASP.NET Web API - 具有可下载示例代码的Screencast系列 http://weblogs.asp.net/jgalloway/archive/2012/03/16/asp-net-web-api-screencast-series-with-downloadable-sample-码部分1.aspx

使用HttpClient使用ASP.NET Web API服务

http://debugmode.net/2012/03/03/creating-first-http-service-using-asp-net-web-api-part1-of-many/ http://debugmode.net/2012/03//07 /使用-HttpClient的-第2部分-的-许多消费-ASP网的Web-API服务

使用ASP.NET Web API和MVC4的CRUD操作

http://www.dotnetglobe.com/2012/03/crud-operation-using-aspnet-web-api-in.html http://www.dotnetglobe.com/2012/03/crud-operation-using-aspnet -Web-API in_28.html

为ASP.Net Web API oData服务创建.Net可查询客户端 http://blog.petegoo.com/index.php/2012/03/11/creating-a-net-queryable-client-for-asp-net-网上API-的OData服务/

使用HttpClient来使用ASP.NET Web API REST服务 http://www.johnnycode.com/blog/2012/02/23/consuming-your-own-asp-net-web-api-rest-service/

使用ASP.NET Web API的客户端支持 https://msmvps.com/blogs/theproblemsolver/archive/2012/03/13/client-side-support-with-the-asp-net-web-api.aspx

创建和使用ASP.Net Web API REST服务 - MVC4 http://www.askamoeba.com/Opensource/Opensourcedetail/144/Create-and-Consume-ASP-Net-Web-API-REST-Services-MVC4

使用MediaTypeFormatter和OData支持使用ASP.NET Web API构建和使用REST服务

http://robbincremers.me/2012/02/16/building-and-consuming-rest-services-with-asp-net-web-api-and-odata-support/

将JSON.NET与ASP.NET Web API一起使用

http://blogs.msdn.com/b/henrikn/archive/2012/02/18/using-json-net-with-asp-net-web-api.aspx

在ASP.NET Web API中为逗号分隔值(CSV)格式创建自定义CSVMediaTypeFormatter

http://www.tugberkugurlu.com/archive/creating-custom-csvmediatypeformatter-in-asp-net-web-api-for-comma-separated-values-csv-format

在ASP.NET Web API中实现CORS支持

http://blogs.msdn.com/b/carlosfigueira/archive/2012/02/20/implementing-cors-support-in-asp-net-web-apis.aspx

我如何看待Web API

http://thedatafarm.com/blog/asp-net/how-i-see-web-api/

c# asp.net-mvc-4 asp.net-web-api

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