Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/security/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 调试和发布模式下的不同自动登录URL_C#_Asp.net_Asp.net Mvc - Fatal编程技术网

C# 调试和发布模式下的不同自动登录URL

C# 调试和发布模式下的不同自动登录URL,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,有可能在一行代码中简化这一点吗 谢谢 public static string BuildAutoLoginUrl(string username) { #if DEBUG return @"/Account/AutoLogin?key=" + GetAutoLoginKey(username); #else return @"http://www.domain.com/Account/AutoLogin?key=" + GetAutoLoginKey(username); #end

有可能在一行代码中简化这一点吗

谢谢

public static string BuildAutoLoginUrl(string username)
{
#if DEBUG
   return @"/Account/AutoLogin?key=" + GetAutoLoginKey(username);
#else
   return @"http://www.domain.com/Account/AutoLogin?key=" + GetAutoLoginKey(username);
#endif
}
不 根据该报告,缔约国声明如下:

预处理器指令必须是行上的唯一指令


因此答案是否定的,不可能将代码减少到一行。

在发布模式下,
www.domain.com
是自动登录请求来自的URL吗?如果是这样的话,为什么不把它仅仅作为第一行,这样做有什么问题?为什么不从config读取它,它可以使用转换@叶海亚:我知道转换,但问题是如何在一行代码中简化转换。@Alberto那只是
ConfigurationManager.AppSettings[“LoginURL”]
。为什么要硬编码URL?为什么要这么做?有一个实用程序函数可用于测试本地url