我的问题:当我使用以下链接时,一切正常:
http://localhost:12816/en/Statistic/Reports
Run Code Online (Sandbox Code Playgroud)
但当我删除"/ en"时 - 我收到应用程序错误:
"'''应用程序中的服务器错误.无法找到资源."
我有几个不同语言的资源文件.当用户请求没有任何语言标识的链接时,我希望我的应用程序使用默认语言(英语).
例如,我希望这些链接完全相同:
http://localhost:12816/Statistic/Reports
http://localhost:12816/en/Statistic/Reports
Run Code Online (Sandbox Code Playgroud)
顺便说一句,我注意到当我要求没有语言的短链接时 - 一切正常:
http://localhost:12816/Statistic/
Run Code Online (Sandbox Code Playgroud)
但是当链接更深时,我得到并且错误
我认为问题在于路由,但我是路由的新手,所以请帮助我:)
PS:我试过这样,但它不起作用:
routes.MapRoute("Default", "{lang}/{controller}/{action}/{id}",
new{
lang = "en",
controller = "Home",
action = "Index",
id = UrlParameter.Optional,
});
routes.MapRoute("Default no language", "{controller}/{action}/{id}",
new
{
controller = "Home",
action = "Index",
id = UrlParameter.Optional
});
Run Code Online (Sandbox Code Playgroud) 我正在编写多线程应用程序。
我需要那种功能:method#1将数据放入Queue<>,然后method#2从Queue中获取数据并进行处理。
Method#2接受2个参数:XElement和FileInfo。如何存储这两个变量以Queue<>备将来使用?
I'm filling TreeView programmatically (in different thread if it matters).
I want the first level of nodes to be expanded when TreeView loads to window. I've tried almost everywhere (in worker thread, in main thread, in event handlers of Form.Load, Form.Shown etc.), but TreeView is still collapsed.
What am I doing wrong ?
UPDATE
treeView.UpdateTree((object tree) => {
treeView.Nodes[0].Nodes.Add(text);
});
public static void UpdateTree(this Control ctrl, Action<object> code) {
if (ctrl.InvokeRequired) {
ctrl.BeginInvoke(code, (TreeView)ctrl);
}
else {
code.Invoke((TreeView)ctrl);
} …Run Code Online (Sandbox Code Playgroud)