小编Bar*_*xto的帖子

从Visual Studio 2013上的应用程序中删除Application Insight

在Visual Studio上,我向项目添加了应用程序洞察,该项目创建了ApplicationInsights.config,并且不确定将哪些其他文件添加到项目中.

事实是,右键单击并按Add Application Insight非常简单.现在我看起来没有成功的方法来删除该项目的应用程序洞察力.

我怎样才能做到这一点?

在生产服务器上,使用DebugView,即使关闭服务器上的Application Monitor Services,我也会看到遥测日志.

任何帮助表示赞赏,我想彻底摆脱对该应用程序的应用程序洞察力.

asp.net visual-studio-2013 azure-application-insights

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

具有数据属性的SelectListItem

无论如何在ViewModel上预先填充了具有数据属性的SelectList吗?

我想要做

@Html.DropdownListFor(m=> m.CityId, Model.Cities);
Run Code Online (Sandbox Code Playgroud)

所以它生成如下代码:

<select id="City" class="location_city_input" name="City">
    <option data-geo-lat="-32.522779" data-geo-lng="-55.765835" data-geo-zoom="6" />
    <option data-geo-lat="-34.883611" data-geo-lng="-56.181944" data-geo-zoom="13" data-geo-name="Montevideo" data-child=".state1" value="1">Montevideo</option>               
    <option data-geo-lat="-34.816667" data-geo-lng="-55.95" data-geo-zoom="13" data-geo-name="Canelones, Ciudad de la Costa" data-child=".state41" value="41">Ciudad de la Costa</option>
</select>
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc html5 html-helper selectlist custom-data-attribute

65
推荐指数
4
解决办法
5万
查看次数

AutoMapper从多个来源转换

假设我有两个模型类:

public class People {
   public string FirstName {get;set;}
   public string LastName {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

还有一类电话:

public class Phone {
   public string Number {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

我想转换为PeoplePhoneDto,如下所示:

public class PeoplePhoneDto {
    public string FirstName {get;set;}
    public string LastName {get;set;}
    public string PhoneNumber {get;set;}
}
Run Code Online (Sandbox Code Playgroud)

让我们在我的控制器中说:

var people = repository.GetPeople(1);
var phone = repository.GetPhone(4);

// normally, without automapper I would made
return new PeoplePhoneDto(people, phone) ;
Run Code Online (Sandbox Code Playgroud)

我似乎找不到这个场景的任何例子.这可能吗 ?

注意:示例不是真实的,仅针对此问题.

c# automapper

59
推荐指数
4
解决办法
4万
查看次数

"命名空间ASP中不存在ASP.global_asax"

我在App_Code上创建了一个RazorFunctions.cshtml文件

@functions {
    public static string GetActiveClassIf(string controllerName, string actionName = null)
    {
        var routeData = @HttpContext.Current.Request.RequestContext.RouteData;
        string currentController = routeData.Values["controller"].ToString();
        string currentAction = routeData.Values["action"].ToString();
        return controllerName == currentController &&
            (String.IsNullOrEmpty(actionName) || currentAction == actionName) ? "active" : "";
    }
}
Run Code Online (Sandbox Code Playgroud)

当我编译时,它给我2个错误(编译获得成功和站点工作没有问题)但错误很烦人.

RazorFunctions.cshtml作为内容(尝试编译但当然不能与cshtml文件一起使用)

Global.asax.cs是:

public class MvcApplication : System.Web.HttpApplication
{
    protected void Application_Start()
    {
        AreaRegistration.RegisterAllAreas();
        ModelMetadataConfig.RegisterModelMetadata();
        FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
        RouteConfig.RegisterRoutes(RouteTable.Routes);
        BundleConfig.RegisterBundles(BundleTable.Bundles);
        Database.SetInitializer(new MigrateDatabaseToLatestVersion<ApplicationDbContext, Configuration>());
        //Database.SetInitializer(new DropCreateDatabaseAlways<ApplicationDbContext>());
    }
}
Run Code Online (Sandbox Code Playgroud)

<%@ Application Codebehind="Global.asax.cs" Inherits="Bouron.Web.MvcApplication" Language="C#" %>
Run Code Online (Sandbox Code Playgroud)

这是我第一次使用App_Code,所以我不知道还能做什么,所有搜索返回ASP.NET 1-2的结果,是剃刀甚至不存在的过时所以我不知道怎么可以我解决了这个问题

我正在使用Visual Studio 2015(以防万一)

c# asp.net asp.net-mvc razor

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

Nuget:远程服务器返回错误:(504)Gateway Timeout

我正在使用Visual Studio 2015预览版CTP 5,我在安装某些软件包时遇到问题.

如果我使用NPM UI,我会得到

The remote server returned an error: (504) Gateway Timeout.
Run Code Online (Sandbox Code Playgroud)

如果我使用PM控制台,Install-Package Ninject.MVC5我得到:

The source at nuget.org [https://www.nuget.org/api/v2/] is unreachable. Falling back to NuGet Local Cache at {userfolder}\AppData\Local\NuGet\Cache
Install-Package : Unable to find package 'Ninject.MVC5'.
Run Code Online (Sandbox Code Playgroud)

如果我键入:Install-Package Ninject.MVC5 -source nuget.org我得到相同的UI错误:

Install-Package : The remote server returned an error: (504) Gateway Timeout.
Run Code Online (Sandbox Code Playgroud)

我试图从其他来源指出解决方案,但没有工作.我在nuget上看到了类似的问题,但根据github repo在15月1日发布了代码'fix'.

我不确定这是不是我的结果还是nuget服务器问题,试图在Twitter上联系他们但仍然没有回应,不知道还有什么可以尝试.

nuget visual-studio-2013 visual-studio-2015

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

无法在Visual Studio RTM中为cordova应用程序启动调试

我有一个正在RC工作的项目,没有任何问题.已更新至RTM,现在无法启动该应用程序

我还创建了一个新的黑色cordova应用程序,仍然无法启动应用程序.

到处看,发现没有提到这个问题.其他人建议不设置环境变量或未安装工具.我三重检查,环境变量很好,确实安装了工具.

我从程序和功能中卸载了所有内容(包括git)并重新安装了vs2015 RTM但没有成功,同样的问题.

我还从android sdk管理器安装了额外的东西,没有运气.

不知道什么是错的,视觉工作室的错误信息没有给出任何线索.

环境路径 错误信息 空的下拉列表 android sdk经理

visual-studio-cordova visual-studio-2015

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

更新服务参考坚持将Soap12添加到Config.

当我更新服务参考时,我最终得到:

无法加载合同"MyService.MainServiceSoap"的端点配置部分,因为找到了该合同的多个端点配置.请按名称指明首选端点配置部分.

我的web.config最终如下:

终点:

  <endpoint address="http://localhost/main/MainService.asmx"
    binding="basicHttpBinding" bindingConfiguration="MainServiceSoap"
    contract="MyService.MainServiceSoap" name="MainServiceSoap" />
  <endpoint address="http://localhost/main/MainService.asmx"
    binding="customBinding" bindingConfiguration="MainServiceSoap12"
    contract="MyService.MainServiceSoap" name="MainServiceSoap12" />
Run Code Online (Sandbox Code Playgroud)

绑定:

  <basicHttpBinding>
    <binding name="MainServiceSoap" closeTimeout="00:01:00" openTimeout="00:01:00"
      receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
      bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
      maxBufferSize="655360" maxBufferPoolSize="5242880" maxReceivedMessageSize="655360"
      messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
      useDefaultWebProxy="true">
      <readerQuotas maxDepth="32" maxStringContentLength="81920" maxArrayLength="163840"
        maxBytesPerRead="40960" maxNameTableCharCount="163840" />
      <security mode="None">
        <transport clientCredentialType="None" proxyCredentialType="None"
          realm="" />
        <message clientCredentialType="UserName" algorithmSuite="Default" />
      </security>
    </binding>
  </basicHttpBinding>
  <customBinding>
    <binding name="MainServiceSoap12">
      <textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
        messageVersion="Soap12" writeEncoding="utf-8">
        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
          maxBytesPerRead="4096" maxNameTableCharCount="16384" />
      </textMessageEncoding>
      <httpTransport manualAddressing="false" maxBufferPoolSize="524288"
        maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
        bypassProxyOnLocal="false" …
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc wcf web-services visual-studio-2010

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

正确使用HTTP错误代码.550 - 为什么它是5xx而不是4xx?

今天,当用户没有权限时,合作者在删除操作上使用了550错误,因为我知道这个错而不是服务器(又名5xx).

在查看说明时,它确切地表明它已被正确使用.而不是401错误,我之前使用的一些'问题'.

401错误的问题是:如果用户A已登录,并尝试执行返回401的操作,则可以建议您必须"登录",因为您没有有效凭据来访问该http资源.这种方法的问题在于,如果用户被记录,服务器知道他没有权限,在这种情况下,看起来像550更合适,但在我看来不应该使用550错误场景.

问题是:在基于Web的应用程序中,550错误的正确用法(如果有)是什么.我理解它在FTP和SMTP中继使用中的用途.如果某些用户登录,则发送不允许的操作请求,应返回哪个错误?

谢谢!

web-applications http-status-codes http-error

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

使用异步控制器的强类型RedirectToAction(Futures)

有这个代码,它给了我一个警告: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call.

    public async Task<ActionResult> Details(Guid id)
    {
        var calendarEvent = await service.FindByIdAsync(id);
        if (calendarEvent == null) return RedirectToAction<CalendarController>(c => c.Index());
        var model = new CalendarEventPresentation(calendarEvent);
        ViewData.Model = model;
        return View();
    }

    public async Task<RedirectResult> Create(CalendarEventBindingModel binding)
    {
        var model = service.Create(binding);
        await context.SaveChangesAsync();
        return this.RedirectToAction<CalendarController>(c => c.Details(model.CalendarEventID));
    }
Run Code Online (Sandbox Code Playgroud)

如果我添加await运算符我得到:

Error …

c# asynchronous asp.net-mvc-futures asp.net-mvc-5

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

在使用区块内不等待是安全的吗?

在这段代码,是安全的等待CopyToAsync实际的复制完成之前或流可以布置?

public Task SaveAsync(Stream source, string filepath)
{
    using (var file = File.OpenWrite(filepath))
    {
        return source.CopyToAsync(file);
    }
}
Run Code Online (Sandbox Code Playgroud)

c# asynchronous

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