我有一个ASP.Net核心应用程序,为了目前的目的,我必须使用LocalAppData.
通常我会写Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),但不幸的是它不能与ASP.Net Core一起使用.
任何人都可以帮我这个吗?
UPDATE
感谢Adem Caglin,我找到了解决方案.
我使用的代码:
Environment.GetEnvironmentVariable(
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "LocalAppData" : "Home");
我有一个ASP.NET核心应用程序.该应用程序需要由Windows服务启动.当服务运行应用程序时,我遇到以下错误:
InvalidOperationException: The view 'Index' was not found. The following locations were searched:
/Views/Home/Index.cshtml
/Views/Shared/Index.cshtml
EnsureSuccessful
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
ThrowForNonSuccess
HandleNonSuccessAndDebuggerNotification
MoveNext
Run Code Online (Sandbox Code Playgroud)
但是,如果我通过单击exe文件来运行应用程序,一切似乎都是正常的.我仔细检查过,服务有足够的权限,视图在正确的位置.
但!我有一种情况,当服务在win32文件夹中的某个地方寻找另一个文件时,因为我犯了一个错误而Directory.GetCurrentDirectory()不是Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)找到当前文件夹.是否有可能出现类似的错误?
我正在使用css属性-column-width(当然-moz-column-width还有-webkit-column-width)来对网页上的内容进行列化.问题是当内容太多时,列化的过程有点慢,并且可能需要几秒钟.我被告知要设置一个微调器来提醒用户该页面尚未就绪,并且微调器也应该阻止UI.但我找不到适当的事件来禁用微调器.该$(document).ready()为时尚早.有任何想法吗?
我有一个带有几个Web Api控制器的ASP.NET Core应用程序.我不知道是否有一些连接,但应用程序是使用VS2015更新2创建的,现在我正在使用VS2015更新3.所以我创建了另一个Web Api控制器,当有一个查询到该控制器时有这个例外:
System.NotSupportedException: The given path's format is not supported.
at System.Security.Permissions.FileIOPermission.QuickDemand(FileIOPermissionAccess access, String fullPath, Boolean checkForDuplicates, Boolean needFullPath)
at System.IO.Path.GetFullPath(String path)
at Microsoft.AspNet.FileProviders.PhysicalFileProvider.GetFullPath(String path)
at Microsoft.AspNet.FileProviders.PhysicalFileProvider.GetFileInfo(String subpath)
at Microsoft.AspNet.StaticFiles.StaticFileContext.LookupFileInfo()
at Microsoft.AspNet.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context)
at Microsoft.AspNet.Cors.Infrastructure.CorsMiddleware.<Invoke>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Microsoft.AspNet.Diagnostics.Entity.MigrationsEndPointMiddleware.<Invoke>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at …Run Code Online (Sandbox Code Playgroud) 我有一个基于Angular2的客户端应用程序.我有一个基类:
abstract class BaseClass {
@HostListener('window:beforeunload') beforeUnloadHandler() {
console.log('bla');
}
}
Run Code Online (Sandbox Code Playgroud)
和两个非常相似的派生类:
@Component({
selector: 'derived-one',
templateUrl: './templates/app/+derived-one/derived-one.component.html'
})
export class DerivedOne extends BaseClass {
}
@Component({
selector: 'derived-two',
templateUrl: './templates/app/+derived-two/derived-two.component.html'
})
export class DerivedTwo extends BaseClass {
}
Run Code Online (Sandbox Code Playgroud)
问题在于,例如,DerivedOne beforeUnloadHandler工作正常,而在DerivedTwo其中根本不接收电话.
我知道很难找到为什么只是查看上面的信息,但也许有人可能会怀疑可能导致这种奇怪行为的原因.
还有一些说明:
如果我使用以下内容:
abstract class BaseClass
constructor(){
window.onbeforeunload = function(){
console.log('bla');
}
}
}
Run Code Online (Sandbox Code Playgroud)
一切正常,但我仍然想找到一个基于Angular2的解决方案;
如果我写
abstract class BaseClass {
beforeUnloadHandler() {
console.log('bla');
}
}
Run Code Online (Sandbox Code Playgroud)
并在 derived-two.component.html
<div (window.beforeunload)="beforeUnloadHandler()"></div>
Run Code Online (Sandbox Code Playgroud)
一切都很好,但它看起来像一个丑陋的黑客;
如果我写的话
abstract class BaseClass {
beforeUnloadHandler() …Run Code Online (Sandbox Code Playgroud) 假设我有以下numpy向量
[[1, 3., 'John Doe', 'male', 'doc', '25'],
...,
[9, 6., 'Jane Doe', 'female', 'p', '28']]
Run Code Online (Sandbox Code Playgroud)
我需要提取与我的任务数据相关的信息.
作为一般的numpy和python的新手,我会以下面的方式做到:
data = np.array(
[[1, 3., 'John Doe', 'male', 'doc', 25],
[9, 6., 'Jane Doe', 'female', 'p', 28]]
)
data_tr = np.zeros((data.shape[0], 3))
for i in range(0, data.shape[0]):
data_tr[i][0] = data[i, 1]
data_tr[i][1] = 0 if data[i, 3] == 'male' else 1
data_tr[i][2] = data[i, 5]
Run Code Online (Sandbox Code Playgroud)
结果我有以下几点:
[[ 3., 0., 25.],
[ 6., 1., 28.]]
Run Code Online (Sandbox Code Playgroud)
我想知道的是,是否有更有效或更清洁的方式来执行该操作.
有人可以帮帮我吗?
我正在学习使用F#进行函数式编程,我想编写一个能为我生成序列的函数.
有一些预定的函数用于转换值,在我需要写入的函数中,应该有两个输入 - 序列的起始值和长度.序列以初始值开始,并且每个后续项是将变换函数应用于序列中的先前值的结果.
在C#中我通常会写这样的东西:
public static IEnumerable<double> GenerateSequence(double startingValue, int n)
{
double TransformValue(double x) => x * 0.9 + 2;
yield return startingValue;
var returnValue = startingValue;
for (var i = 1; i < n; i++)
{
returnValue = TransformValue(returnValue);
yield return returnValue;
}
}
Run Code Online (Sandbox Code Playgroud)
当我试图将此函数转换为F#时,我做了这个:
let GenerateSequence startingValue n =
let transformValue x =
x * 0.9 + 2.0
seq {
let rec repeatableFunction value n =
if n = 1 then
transformValue value
else
repeatableFunction (transformValue …Run Code Online (Sandbox Code Playgroud) asp.net-core ×3
c# ×3
angular ×1
css ×1
f# ×1
html ×1
javascript ×1
jquery ×1
numpy ×1
python ×1
python-3.x ×1
static-files ×1
typescript ×1