将asp.net核心角度应用程序部署到iis

问题描述

我创建了一个ASP.NET Core Angular应用程序 Project Structure

我正在尝试将其部署到IIS中,但是有一些问题。 我将其上传到服务器中,但是正如您在控制台日志中看到的那样,如果进入“获取数据”选项卡this error appears

在localhost中,一切正常。我做了publish to folder之后 并将其上传到我的服务器,客户端无法通过HTTP访问它。

这是asp.net核心控制器功能:

@model VievModel.MyView

Return View("MyView",ratingConverter);

这是来自角度组件的HTTP get请求:

 [HttpGet("[action]")]
        public IEnumerable<Country> GetCountries()
        {
            List<Country> countries;
            var dictionary = new Dictionary<string,string>();

            try
            {
                var client = new RestClient("https://restcountries-v1.p.rapidapi.com/all");
                var request = new RestRequest(Method.GET);
                request.AddHeader("x-rapidapi-host","restcountries-v1.p.rapidapi.com");
                request.AddHeader("x-rapidapi-key","a75567071fmsh1da754f34ee180dp16140cjsnd0ce561437aa");
                IRestResponse response = client.Execute(request);

                countries = JsonConvert.DeserializeObject<List<Country>>(response.Content);

            }
            catch
            {
                string countriesJson = System.IO.File.ReadAllText("c:\\tmp\\countries.json");
                countries = JsonConvert.DeserializeObject<List<Country>>(countriesJson);
            }


            foreach (Country c in countries)
            {
                dictionary.Add(c.alpha3Code,c.name);
            }
            


            return Enumerable.Range(0,countries.Count - 1).Select(index => new Country
            {
                name = countries[index].name,capital = countries[index].capital,languages = countries[index].languages,timezones = countries[index].timezones,borders = countries[index].borders.Select(s => dictionary[s]).ToList(),flag = "https://www.countryflags.io/" + countries[index].alpha2Code + "/flat/64.png",population = countries[index].population,nativeName = countries[index].nativeName,currencies = countries[index].currencies,region = countries[index].region,});
        }

这也是.angular-cli.json文件:

 http.get<Country[]>(baseUrl + 'api/Countries/GetCountries').subscribe(result => {
      this.countreis = result;
      this.filterCountries = this.countreis;

      this.config = {
        itemsPerPage: 10,currentPage: 1,totalItems: this.countreis.length
      };


    },error => console.error(error));

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...