错误如:未找到视图"LoginRegister"或其主控或没有视图引擎支持搜索的位置.搜索了以下位置:
〜/查看/我的帐户/ LoginRegister.aspx
〜/查看/我的帐户/ LoginRegister.ascx
〜/查看/共享/ LoginRegister.aspx
〜/查看/共享/ LoginRegister.ascx
〜/查看/我的帐户/ LoginRegister.cshtml
〜/查看/我的帐户/ LoginRegister.vbhtml
〜/查看/共享/ LoginRegister.cshtml
〜/查看/共享/ LoginRegister.vbhtml
实际上我的页面浏览页面就是 ~/Views/home/LoginRegister.cshtml我所做的
而我的RouteConfig是
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "MyAccount", action = "LoginRegister", id = UrlParameter.Optional }
);
}
}
Run Code Online (Sandbox Code Playgroud) ASP.NET MVC 在 TEST Server 中引发以下错误,我无法在 Developer 机器中重现该错误。
尝试从 MVC 连接到 WebAPI 服务并收到错误
只允许使用“http”和“https”方案。参数名称:requestUri
我无法从其他问题中得到答案,因为他们主要是在谈论 WCF 绑定。
代码:
var credentials = "username:Password";
var encoded = Convert.ToBase64String(System.Text.Encoding.ASCII.GetBytes(credentials));
this.client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", encoded);
System.Net.Http.HttpClient client = new HttpClient();
HttpResponseMessage response = client.GetAsync(URL).Result;
Run Code Online (Sandbox Code Playgroud)
注意:通过浏览器访问 WebAPI URL 会返回数据。