我当时可以注释掉一行#
,但是有多行评论切换键盘快捷键吗?
我正在关注ASP.NET 5的一些示例,我偶然发现了如何正确读取"嵌套"配置值(如果这是正确的术语).
以下是相关部分config.json
:
{
"ApplicationName" : "OwNextApp",
"AppSettings": {
"SiteTitle": "OwNext"
},
}
Run Code Online (Sandbox Code Playgroud)
相关部分HomeController.cs
:
public IActionResult About()
{
var appNestedNameFailed = _config.Get("AppSettings.SiteTitle");
var appNestedNameSuccess = _config.Get("AppSettings:SiteTitle");
var appName = _config.Get("ApplicationName");
ViewBag.Message = string.Format(@"Your
APP NAME: {0};
APP NESTED NAME FAILED: {1};
APP NESTED NAME SUCCESS: {2}",
appName, appNestedNameFailed, appNestedNameSuccess);
return View();
}
Run Code Online (Sandbox Code Playgroud)
对于值appNestedNameFailed
是空的(研究之前我最初的尝试).并且appNestedNameSuccess
有价值; 在我进行研究并在配置测试中找到(相关代码显示):
// Assert
Assert.Equal("IniValue1", config.Get("IniKey1"));
Assert.Equal("IniValue2", config.Get("IniKey2:IniKey3"));
Run Code Online (Sandbox Code Playgroud)
有人可以解释为什么会这样吗?为什么使用:
结束有意义.
?从我与JSON数据的交互,通常. …
我正在尝试使用MVC4进行文件上传,但是在DB中保存对象名称"System.Web.HttpPostedFileWrapper"而不是文件名即"Songs.MP3",同时文件也不会传输到给定位置.
模型
public class FileUpload
{
[Key]
public int FileUploadID { get; set; }
public int AlbumID { get; set; }
public string FileType { get; set; }
public string FileUploadLocation { get; set; }
public virtual Albums Albums { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
视图
@using (Html.BeginForm("Create", "FileUpload", FormMethod.Post, new { enctype = "multipart/form-data" }))
Run Code Online (Sandbox Code Playgroud)
{
<div class="editor-label">
@Html.LabelFor(model => model.FileUploadLocation)
</div>
<div class="editor-field">
@Html.TextBoxFor(model => model.FileUploadLocation, new { type = "file", accept = "FileUploadLocation/*" })
@Html.ValidationMessageFor(model => model.FileUploadLocation)
</div> …
Run Code Online (Sandbox Code Playgroud) 我使用创建了新的vue.js应用程序vue init webpack my-test3
。
在VS Code(v1.7.1)中,我尝试调试此应用程序,并且默认情况下launch.json
将程序设置为:
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/app.js",
"cwd": "${workspaceRoot}"
},
Run Code Online (Sandbox Code Playgroud)
但app.js
不存在。我需要创建app.js
哪些内容(如果需要)?如果没有,我要指向哪里program
?还是我需要做一些完全不同的事情?
更新1
好的,所以我尝试更改program
为指向/src/main.js
。现在抛出ES 2015
错误。
(function (exports, require, module, __filename, __dirname) { import
Vue from 'vue'
^^^^^^ SyntaxError: Unexpected token import
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Timeout.Module.runMain [as _onTimeout] (module.js:604:10) …
Run Code Online (Sandbox Code Playgroud) 在下面的代码中:
void Main()
{
DateTime cleanDate = DateTime.Now.ToCleanDateTime();
DateTime? nullableCleanDate = DateTime.Now;
nullableCleanDate = nullableCleanDate.ToCleanDateTime();
cleanDate.Dump();
nullableCleanDate.Dump();
}
public static class Extensions
{
//public static DateTime ToCleanDateTime(this DateTime dt)
//{
// dt = new DateTime(dt.Year, dt.Month, dt.Day, 0, 0, 0, 0);
// return dt;
//}
public static DateTime? ToCleanDateTime(this DateTime? dt)
{
if (dt.HasValue)
dt = new DateTime(dt.Value.Year, dt.Value.Month, dt.Value.Day, 0, 0, 0, 0);
return dt;
}
}
Run Code Online (Sandbox Code Playgroud)
该行DateTime cleanDate = DateTime.Now.ToCleanDateTime();
引发以下异常.
'System.DateTime'不包含'ToCleanDateTime'的定义,最好的扩展方法重载'Extensions.ToCleanDateTime(System.DateTime?)'有一些无效的参数
如果我在扩展方法中发表评论,DateTime
public static DateTime …
如果我尝试访问web.config
服务器返回的消息HTTP Error 404.8 - Not Found
(请求过滤模块配置为拒绝URL中包含hiddenSegment部分的路径。)
如果我尝试访问packages.config
服务器返回的消息HTTP Error 404.7 - Not Found
(请求过滤模块配置为拒绝文件扩展名。)
现在我知道为什么这两个被阻止/过滤了。但我不确定为什么package.json不是。
.json
Web服务器(IIS)需要提供服务的其他文件吗?asp.net ×2
c# ×2
asp.net-core ×1
c#-4.0 ×1
config.json ×1
datetime ×1
debugging ×1
file-upload ×1
http-error ×1
iis ×1
json ×1
node.js ×1
nullable ×1
package.json ×1
vue.js ×1