小编Ger*_*sen的帖子

VS 2015 MVC6引用/依赖性错误

我刚刚将我的VS 2015 RC升级到MSDN的最终版本.然后我尝试添加一个新项目,一个MVC 6项目.

但没有任何作用,错误列表为空.如果我尝试构建,它似乎永远等待,最终我必须取消构建过程 - 没有错误atall,它只是不构建. - 理所当然,因为从下面的屏幕截图中可以看出,Core和DNX的大多数引用都标有黄色错误三角形.

但至少我会喜欢某种错误信息或其他如何解决这个问题的提示.

我对项目进行了零更改,因此它应该已经开箱即用.除了"WindowsAzure.Storage"引用之外,我想我添加了一个,但是一个或多或少没有任何区别,我只是想看看我通过nuGet管理器添加的任何引用是否会更好,但是它们别.

大多数参考文献都是开箱即用的错误

不确定它是否有用,但这里是相关项目的默认project.json的副本:

{
  "webroot": "wwwroot",
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.AspNet.Diagnostics": "1.0.0-beta5",
    "Microsoft.AspNet.Mvc": "6.0.0-beta5",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-beta5",
    "Microsoft.AspNet.Server.IIS": "1.0.0-beta5",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-beta5",
    "Microsoft.AspNet.StaticFiles": "1.0.0-beta5",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-beta5",
    "Microsoft.Framework.Configuration.Json": "1.0.0-beta5",
    "Microsoft.Framework.Logging": "1.0.0-beta5",
    "Microsoft.Framework.Logging.Console": "1.0.0-beta5",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-beta5",
    "WindowsAzure.Storage": "4.4.1-preview"
  },

  "commands": {
    "web": "Microsoft.AspNet.Hosting --config hosting.ini"
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
  ],
  "publishExclude": [
    "node_modules",
    "bower_components",
    "**.xproj",
    "**.user",
    "**.vspscc"
  ],
  "scripts": {
    "prepublish": [ "npm install", …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-mvc visual-studio-2015 asp.net-core

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

MVC 6 WebAPI返回序列化的HttpResponseMessage而不是文件流

我正在尝试让我的ASP.Net 5 MVC 6 WebAPI项目输出一个文件,以响应HttpGET请求.

该文件来自Azure Files共享,但它可以是包含二进制文件的任何流.

在我看来,MVC序列化响应对象,并返回结果JSON,而不是返回响应对象本身.

这是我的控制器方法:

    [HttpGet]
    [Route("GetFile")]
    public HttpResponseMessage GetFile(string Username, string Password, string FullName)
    {

        var client = new AzureFilesClient.AzureFilesClient(Username, Password);
        Stream azureFileStream =  client.GetFileStream(FullName).Result;
        var fileName = Path.GetFileName(FullName);

        using (HttpResponseMessage response = new HttpResponseMessage(HttpStatusCode.OK))
        {
            response.Content = new StreamContent(azureFileStream);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
            response.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = fileName };
            return response;
        }
    }
Run Code Online (Sandbox Code Playgroud)

AzureFilesClient上的GetFileStream方法在此处,但流源可以是包含二进制文件内容的任何内容:

    public async Task<Stream> GetFileStream(string fileName)
    {
        var uri = new Uri(share.Uri + "/" + fileName);
        var file …
Run Code Online (Sandbox Code Playgroud)

asp.net asp.net-mvc asp.net-web-api

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

VB.Net中的文件比较

我需要知道两个文件是否相同.起初我比较了文件大小和创建时间戳,但这不够可靠.我已经提出了以下代码,这似乎有效,但我希望有人能够更好,更容易或更快地完成这项工作.

基本上我正在做的是将文件内容流式传输到字节数组,并通过System.Security.Cryptography比较它们的MD5哈希值.

在此之前,我做了一些简单的检查,因为没有理由读取文件,如果两个文件路径相同,或者其中一个文件不存在.

Public Function CompareFiles(ByVal file1FullPath As String, ByVal file2FullPath As String) As Boolean

    If Not File.Exists(file1FullPath) Or Not File.Exists(file2FullPath) Then
        'One or both of the files does not exist.
        Return False
    End If

    If String.Compare(file1FullPath, file2FullPath, True) = 0 Then
        ' fileFullPath1 and fileFullPath2 points to the same file...
        Return True
    End If

    Dim MD5Crypto As New MD5CryptoServiceProvider()
    Dim textEncoding As New System.Text.ASCIIEncoding()

    Dim fileBytes1() As Byte, fileBytes2() As Byte
    Dim fileContents1, fileContents2 As String
    Dim streamReader As …
Run Code Online (Sandbox Code Playgroud)

vb.net comparison filestream

4
推荐指数
1
解决办法
3866
查看次数