我想增加httpRuntime executionTimeout一个ASP.NET MVC应用程序的子部分.
在常规Web应用程序中,您可以使用:
<configuration>
<location path="UploadPage.aspx">
<httpRuntime executionTimeout="600"/>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
但是,ASP.NET MVC中确实没有"文件夹"的概念,那么我该怎样做呢?
让我们假设ASP.NET MVC路径是/Images/Upload使用ImagesController和Upload Action.
根据此处发现的大量信息,我们如何才能使外部.config工作?我尝试了相同的设置,我将用于外部appSettings文件,但它无法找到我的自定义部分的文件.
<configSections>
...
<section name="CustomSettings" type="Fully.Qualified.TypeName.CustomSettings, AssemblyName" />
</configSections>
<!-- this works -->
<CustomSettings attrib1="val1" attrib2="val2" .../>
Run Code Online (Sandbox Code Playgroud)
然而...
<!--this does not work-->
<CustomSettings configSource="someExternalFile.config"/>
Run Code Online (Sandbox Code Playgroud)
someExternalFile.config包含的位置
<CustomSettings attrib1="val1" attrib2="val2" .../>
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
业务规则违规是否会引发异常?
我想做的是在保持迭代器的同时使用LINQ的优雅......
实质上
Class A
{
int Position;
string Name;
}
Run Code Online (Sandbox Code Playgroud)
如果我有一个字符串列表,我想将它们List<A>投影到但是在投影中填充了位置...
List<string> names; //filled with strings
Run Code Online (Sandbox Code Playgroud)
就像是
List<A> foo = (from s in names select s).ToList();
Run Code Online (Sandbox Code Playgroud)
但它还迭代并填充位置..
这可能吗?
{{Position:0,Name: "name1"},{Position:1, Name: "name2"}, {Position:2, Name: "name3"}....}
Run Code Online (Sandbox Code Playgroud) 你有一个有2个参数的类的方法,其中一个是文件路径,另一个是不相关的.
InterestingResult result = foo.Bar(irrelevant, filePathInfo);
Run Code Online (Sandbox Code Playgroud)
本着快速快速单元测试的精神,你发现自己正在考虑重构这个方法来拉出文件路径来删除这个测试的IO要求......最有可能把它放到另一个方法中,所以现在你可以调用
string dataInFile = foo.GetDataInFile(filePathInfo);
InterestingResult result = foo.Bar(irrelevant, dataInFile);
Run Code Online (Sandbox Code Playgroud)
你疯了吗?......或者这是件好事吗?
c# ×3
.net ×1
app-config ×1
asp.net ×1
asp.net-mvc ×1
exception ×1
httpruntime ×1
linq ×1
refactoring ×1
rules ×1
timeout ×1
unit-testing ×1