小编Ric*_*olo的帖子

MVC4中的Styles.Render

在一个.NET MVC4项目中如何@Styles.Render运作?

我的意思是,它在@Styles.Render("~/Content/css")哪个文件中调用?

我的文件夹中没有文件或名为"css"的Content文件夹.

c# asp.net-mvc razor asp.net-mvc-4

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

MVC4 Bundle中的{version}通配符

在MVC 4中,我们有捆绑.在定义包时,我们可以使用*等通配符来处理文件夹中的所有文件.

在下面的例子中是什么-{version}意思?

public static void RegisterBundles(BundleCollection bundles)
{
    bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
        "~/Scripts/jquery-{version}.js"));
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net asp.net-mvc asp.net-mvc-4 asp.net-optimization

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

ASP.NET MVC框架4.5 CSS包不适用于托管

我正在使用MVC4编写的app ports上运行一个应用程序.

一捆css文件不起作用.在调试模式的本地计算机中,我看到了应用程序的代码,我看到了文件.该应用程序按预期工作.

<link href="/Content/css/home/basic-jquery-slider.css" rel="stylesheet"/>
<link href="/Content/css/home/Home.css" rel="stylesheet"/>
Run Code Online (Sandbox Code Playgroud)

当我将应用程序上传到Appharbor时,我在代码中看到了捆绑包但是App无法正常工作.

<link href="/Content/css/home?v=zhVOIpUNuvCOZhJyBcQWpMlozayor4te6k-pM29wHqI1" rel="stylesheet"/>
Run Code Online (Sandbox Code Playgroud)

当我浏览那个链接时,href我得到403 - 禁止访问:访问被拒绝.

如何解决这个问题?

asp.net-mvc appharbor asp.net-mvc-4 asp.net-optimization

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

在同一个Controller中具有相同Action名称的GET和POST方法

为什么这不正确?

{
    public class HomeController : Controller
    {

        [HttpGet]
        public ActionResult Index()
        {
            Some Code--Some Code---Some Code
            return View();
        }

        [HttpPost]
        public ActionResult Index()
        {
            Some Code--Some Code---Some Code
            return View();
        }

    }
Run Code Online (Sandbox Code Playgroud)

我怎样才能让控制器在"getted"时回答一件事,在"发布"时回答一件事?

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

76
推荐指数
5
解决办法
10万
查看次数

在Powershell中将对象添加到对象数组中

我有这个脚本,我想$Target在每个foreach中调用的数组中添加一个对象.

foreach ($Machine in $Machines)
{
  $TargetProperties = @{Name=$Machine}  
  $TargetObject = New-Object PSObject –Property $TargetProperties
  $Target= @()
  $Target =  $TargetObject
}
Run Code Online (Sandbox Code Playgroud)

我知道它不起作用,因为$Target = $TargetObject它使它等于同一个对象.

如何附加到数组而不是替换?

arrays powershell scripting

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

冒号(:)意味着在c#中定义一个类?

在c#中定义一个类是什么:意思?

例如,在ASP.NET MVC应用程序的这个非常基本的控制器中:

namespace App.Controllers
{
    public class HomeController : Controller
    {    
        public ActionResult Index()
        {
            return View();
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

在第三行,: Controller意味着什么?

c#-4.0 asp.net-mvc-3

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

Razor中()(括号)和{}(花括号)之间的差异

它们之间有什么区别.我以为他们是一样的,但今天我意识到他们不是.

为什么这是正确的

@(Model.WillAttend == true ? 
    "This will be an exciting party with you" : 
    "So sorry. You'll lose the beeer")
Run Code Online (Sandbox Code Playgroud)

这不是:

@{Model.WillAttend == true ? 
    "This will be an exciting party with you" : 
    "So sorry. You'll lose the beeer"}
Run Code Online (Sandbox Code Playgroud)

asp.net-mvc razor asp.net-mvc-3

23
推荐指数
3
解决办法
7868
查看次数

剃须刀更换的优点(@href)

在ASP.NET MVC的文档中说,当在视图中有链接时,你应该做这样的事情

<a href="@href("~/SubPage")">Subpage</a>.
Run Code Online (Sandbox Code Playgroud)

剃刀引擎取代@href("~/SubPage")/Subpage.

这样做有什么好处呢

<a href="/SubPage">Subpage</a>.
Run Code Online (Sandbox Code Playgroud)

在这种情况下以及在其他情况下(比如创建表单),为什么要使用剃刀引擎而不是直接写出你想要的东西.我认为在服务器端更快地直接打印让引擎生成它的东西.

asp.net-mvc razor asp.net-mvc-3

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

AcquireTokenSilent始终无法以静默方式获取令牌

使用ADAL我有两个AuthenticationContext使用SQL中持久化的令牌缓存.

使用AcquireTokenByAuthorizationCode它在数据库中写入令牌,但在使用时AcquireTokenSilent我总是得到

无法以静默方式获取令牌.调用方法AcquireToken

以下是复制问题的详细信息:

我创建了一个Context

AuthenticationContext authContext = new AuthenticationContext(_authority, new AzureAdalCache(companyId, _entries, _unitOfWork));
Run Code Online (Sandbox Code Playgroud)

然后我通过授权获取授权

authContext.AcquireTokenByAuthorizationCode(authorizationCode, new Uri(redirectUri), _clientCredential);
Run Code Online (Sandbox Code Playgroud)

此时,它会在数据库中保存一个条目

然后,如果我打电话给我,我得到一个例外.

authContext.AcquireTokenSilent(_authority, _clientCredential, new UserIdentifier(companyId.ToString(), UserIdentifierType.UniqueId)).AccessToken;
Run Code Online (Sandbox Code Playgroud)

我也尝试过相同的结果:

authContext.AcquireTokenSilent(_authority, _clientId).AccessToken;
authContext.AcquireTokenSilent(_authority, _clientCredential, UserIdentifier.AnyUser).AccessToken;
Run Code Online (Sandbox Code Playgroud)

AzureAdalCache这个要点中发布我的实现.

Cache的每个条目都是这样的.

我错过了什么?

更新

根据@vibronet的评论回答,我有这个

AuthenticationContext authContext = new AuthenticationContext(_authority, new AzureAdalCache(companyId, _entries, _unitOfWork));
authContext.AcquireTokenByAuthorizationCode(authorizationCode, new Uri(redirectUri), _clientCredential, _eWSResource);
string result = authContext.AcquireTokenSilent(_eWSResource, _clientId, UserIdentifier.AnyUser).AccessToken;
Run Code Online (Sandbox Code Playgroud)

oauth azure azure-active-directory adal azure-webjobs

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

如何进行需要其子函数信息的回调

我正在使用Node.js作为Haraka(一个smtp服务器)插件的项目.

这是Node.JS,我有一个问题回调.我无法将此特定代码转换为使用回调.

所以,这是我的代码:

exports.hook_data = function (next, connection) {
    connection.transaction.add_body_filter('', function (content_type, encoding, body_buffer) {
        var header = connection.transaction.header.get("header");
        if (header == null || header == undefined || header == '') return body_buffer;

        var url = 'https://server.com/api?header=' + header ;
        var request = require('request');
        request.get({ uri: url },
          function (err, resp, body) {
              var resultFromServer = JSON.parse(body);
              return ChangeBuffer(content_type, encoding, body_buffer, resultFromServer);
          }
        );
    });
    return next();
}
Run Code Online (Sandbox Code Playgroud)

此代码不起作用,因为它不等待Request的回调继续.我需要先完成请求next();

这些是要求:

  1. 在结束时exports.hook_data必须返回next().但它只需要在请求后返回它.
  2. 我需要返回一个 …

javascript callback node.js haraka

14
推荐指数
1
解决办法
390
查看次数