小编Sas*_*iel的帖子

如何在asp.net MVC 4和Razor视图中显示路径中的图像?

我有以下型号:

public class Player
{


    public String ImagePath
    {
        get
        {
            return "~/Content/img/sql_error.JPG";
        }

    }
Run Code Online (Sandbox Code Playgroud)

而且,这是我的.cshtml档案:

@model SoulMasters.Models.Game.Player

@{
ViewBag.Title = "Game";
Layout = "~/Views/Shared/_GameLayout.cshtml";
var imagePath = @Model.ImagePath;
}

<fieldset>
<legend>Player</legend>

   <div class="display-field">
    @Html.DisplayFor(model => model.ImagePath)
</div>
@imagePath
<div style="padding:10px;">

    <img src=@imagePath alt="Sample Image" width="300px" />

    <img  alt="asd" >
        model.ImagePath;
    </img>
</div>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

结果是简单的文字:

~/Content/img/sql_error.JPG
~/Content/img/sql_error.JPG
Sample Image asd model.ImagePath;
Run Code Online (Sandbox Code Playgroud)

此外,我尝试了以下行,它的工作原理:

<img src="~/Content/img/sql_error.JPG" alt="Sample Image" width="300px" />
Run Code Online (Sandbox Code Playgroud)

如何从路径显示该图像?根据设置,图像路径可能不同吗?还有其他想法吗?

关于剃刀语法是如何工作的,我现在还没有真正理解它.

asp.net-mvc image razor

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

DateTime.AddDays()无法按预期工作

我有这个简单的程序:

        DateTime aux = new DateTime(2012, 6, 12, 12, 24, 0);
        DateTime aux2 = new DateTime(2012, 6, 12, 13, 24, 0);
        aux2.AddDays(1);

       Console.WriteLine((aux2 - aux).TotalHours.ToString());

        Console.ReadLine();
Run Code Online (Sandbox Code Playgroud)

我调试了这个,发现aux2.AddDays(1);似乎不起作用,我在这里缺少什么?它应该返回25但答案是一个.

问题是什么?

AddHours行不通,我猜其他人也不行.

c# datetime visual-studio-2010

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

从datagrid中的行中的选定单元格中删除边框

正如你在Jesse Furher周围的图片中看到的那样是一条黑色边框线,我怎样才能删除所有细胞的那条线?

例

wpf xaml styles

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

从url读取数据会返回空值

我有这个代码创建一个请求并读取数据,但它总是为空

        static string uri = "http://yiimp.ccminer.org/api/wallet?address=DshDF3zmCX9PUhafTAzxyQidwgdfLYJkBrd";

    static void Main(string[] args)
    {

        HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri);
        request.AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip;

        HttpWebResponse response = (HttpWebResponse)request.GetResponse();

        // Get the stream associated with the response.
        Stream receiveStream = response.GetResponseStream();

        // Pipes the stream to a higher level stream reader with the required encoding format. 
        StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8);

        Console.WriteLine("Response stream received.");
        Console.WriteLine(readStream.ReadToEnd());
        response.Close();
        readStream.Close();

    }
Run Code Online (Sandbox Code Playgroud)

当我尝试从浏览器访问链接时,我得到这个json:

{"currency": "DCR", "unsold": 0.030825917365192, "balance": 0.02007306, "unpaid": 0.05089898, "paid24h": 0.05796425, "total": 0.10886323}
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

c# httpwebrequest

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

Windows 8 app如何连接到Socket服务器

我使用这个示例socketAsyncEventArgs完成了一个服务器

在visual studio 2010和.net 4.0中.

现在我正在尝试使用StreamSocket从Windows 8应用程序连接到它,但我得到一个"Acces denied"消息.这是客户端代码:

private StreamSocket streamSocket;
    public string Server = "192.168.0.101";
    public int Port = 9900;

    public async void Connect()
    {
        streamSocket = new StreamSocket();
        Connect();
        try
        {
            await streamSocket.ConnectAsync(
                new Windows.Networking.HostName(Server),
                Port.ToString()); // getting Acces Denied here

            DataReader reader = new DataReader(streamSocket.InputStream);
            reader.InputStreamOptions = InputStreamOptions.Partial;
            while (true)
            {
                var bytesAvailable = await reader.LoadAsync(1000);
                var byteArray = new byte[bytesAvailable];
                reader.ReadBytes(byteArray);

            }
        }
        catch (Exception e)
        {
            MessageBox(e.StackTrace);
        }
    }
Run Code Online (Sandbox Code Playgroud)

如何解决问题?是否有另一种使用此服务器发送和接收消息的方法?

c# sockets windows-8

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

Cloudformation-'AWS_PROXY'当前仅支持Lambda函数

我想使用cloudformation创建堆栈时出现以下错误:

The following resource(s) failed to create: [ApiSyncLogsPost]. . Rollback requested by user.
CREATE_FAILED   AWS::ApiGateway::Method ApiSyncLogsPost Integrations of type 'AWS_PROXY' currently only supports Lambda function and Firehose stream invocations. (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: 8bff48b0-93e4-11e8-a183-5de2b976f282)
Run Code Online (Sandbox Code Playgroud)

我在Google上没有发现与此错误相关的任何信息,当我搜索它时,我只得到了很多AWS Cloudformation文档。

我认为正在发生的是 ApiSyncLogsPost资源定义不正确,但是我在互联网上发现的示例与此类似。

为了解决该错误需要更改什么?

这是cloudformation json:

{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata": {
    "AWS::CloudFormation::Designer": {
        "a73e3686-2291-49a2-b052-565c5f85a9c9": {
            "size": {
                "width": 60,
                "height": 60
            },
            "position": {
                "x": 270,
                "y": 120
            },
            "z": 2,
            "parent": "d68e59d4-72c0-425a-9b7b-227cbac3252d",
            "embeds": []
        },
        "0665ec07-964b-4c90-86c5-5f7731cece7b": { …
Run Code Online (Sandbox Code Playgroud)

aws-cloudformation aws-lambda aws-api-gateway

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