【发布时间】:2019-11-13 01:19:21
【问题描述】:
我对 AngularJS 和 SQL Server 配置问题非常陌生。
我使用 ASP.NET MVC 5 开发了 AngularJS 应用程序。基本上,前端基于 AngularJS,后端使用 C#。
一旦我们将应用程序放到 SQL Server 中,应用程序就会按预期工作。为了运行应用程序,我从 Web.Config 文件中获取了 SurveyID = 1(比如说)。
现在,我想为多个调查使用不同的 SurveyID 运行相同的应用程序。
a. The server folder is \\Survey with SurveyID = 1
b. The server folder is \\Survey2 with SurveyID = 2
c. The server folder is \\Survey3 with SurveyID = 3
d. The server folder is \\Survey4 with SurveyID = 4
即使应用程序放入不同的文件夹结构,应用程序始终会读取恰好是 \Survey 且 SurveyID = 1 的根文件夹
但在 MVC Layout_Page 中,我使用的是 HTML 标签 我想知道这是否是根本问题的原因。
现在,我如何根据 Web.Config SurveyID 告诉 angularJS 应用哪个是根目录
我该如何解决这个问题? MVC HOME 控制器内部
DataAccessSurvey data;
int surveyID;
public HomeController()
{
data = new DataAccessSurvey();
surveyID = Convert.ToInt32(ConfigurationManager.AppSettings["SurveyId"]);
}
[HttpGet]
public ActionResult GetSurveyInfoData()
{
var surveyData = data.GetSurveyById(surveyID);
var Survey = new Survey();
//the rest of the code to populate the Survey related data
}
在 Angular Controller.jS 中我调用以下方式
SurveyServices.getSurveyData()
.then(function (result) {
//alert("Success getSurveyData GetSurveyInfoData");
vm.SurveyInfo = result.data;
}
请帮帮我。 提前致谢。
【问题讨论】:
标签: c# asp.net angularjs asp.net-web-api