gpt4 book ai didi

c# - 从 web api 调用 aspx 页面时出现“无效的 URI : The format of the URI could not be determined.”

转载 作者:行者123 更新时间:2023-11-30 21:28:34 25 4
gpt4 key购买 nike

我想从我的方法调用 aspx 页面,所以我使用 Redirect() 方法如下:

pubic calsss mainController:ApiController
{
[HttpPost]
public void postReport()
{
Redirect("/WebForm1.aspx");
}
}

但是当我使用它时,它显示了这个异常:“无效的 URI:无法确定 URI 的格式。”

我的 WebForm1.aspx 是一个内部页面。有人可以帮我解决这个问题吗?

更新:

我的网络配置:

public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services

// Web API routes
config.MapHttpAttributeRoutes();

config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "withAction",
routeTemplate: "api/{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
config.Routes.MapHttpRoute(
name: "noApi",
routeTemplate: "{controller}/{action}/{id}",
defaults: new { id = RouteParameter.Optional }
);
}
}

我的项目结构:

enter image description here

最佳答案

你能不能像这样替换你的代码:

return Redirect("~/Webform1.aspx");

关于c# - 从 web api 调用 aspx 页面时出现“无效的 URI : The format of the URI could not be determined.”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56359827/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com