我做了一个OData服务,我想做一个客户端程序来调用这个服务。我想使用OData v4客户端代码生成器,但无法在Visual Studio 2019中安装它,而只能在vs2017中安装它。
我如何在vs2019中安装它?
我有一个 asp.net 核心 odata api。我想为这个 api 启用 swagger。asp.net core的版本是2.2,这个项目的依赖如下图:
启动配置如下:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
services.AddDbContext<SeeMiddleContext>(options =>
{
options.UseSqlServer(
"Data Source = 192.168.1.1;Initial Catalog=Seem;persist security info=True;user id=Sas;password=Sas1");
});
services.AddOData();
services.AddSwaggerGen(options =>
{
options.DescribeAllEnumsAsStrings();
options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info { Title = "eShopOnContainers - Catalog HTTP API", …Run Code Online (Sandbox Code Playgroud) 我有一个 OData api,并为此启用了 swagger。当我将 OData api 的 json 信息粘贴到“editor.swagger.io”中时,它会给出错误:(路径中的语义错误。/BankBranches.get.responses.200.schema.$ref $ref 值必须是 RFC3986 - 符合百分比编码的 URI)
我的回复如下:
响应:'200':描述:好的架构:$ref:'#/definitions/ODataResponse[List[BankBranch]]'
我知道我可以通过删除所有“[”,“]”来解决问题,但这太难了,并且在大型项目中花费了太多时间。我不知道如何更改我的 OData api 以避免出现此问题?
在我的 ASP.NET MVC 项目中,我在 Web.config 中有以下配置:
<configSections>
<section name="nlog" type="NLog.Config.ConfigSectionHandler, NLog" />
</configSections>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<targets>
<target name="default" xsi:type="File" fileName="logs/app-log.txt" layout="
--------------------- ${level} (${longdate}) ----------------------$
IP: ${aspnet-request-ip}
Call Site: ${callsite}
${level} message: ${message}"/> archiveFileName="logs/archives/app-log.{#}.txt" archiveEvery="Day" archiveNumbering="Rolling" maxArchiveFiles="7" />
</targets>
<rules>
<logger name="*" writeTo="default" />
</rules>
</nlog>
Run Code Online (Sandbox Code Playgroud)
如果我的日志消息是波斯语文本,那么在日志文件中我有问号?????不是波斯语文本。
我该如何解决这个问题?任何帮助将不胜感激!
我有一个 ASP.NET Core MVC 项目(Core 的版本是 3),我必须至少处理两个异常,例如 404 和 500,并且有一个 404 的视图,应该说“对不起,找不到页面”,否则错误 500 的另一个页面应该说“处理您的请求时发生错误”。这些页面必须具有 DefaultLayout。我的 Startup.cs 如下:
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddControllersWithViews();
services.AddDistributedMemoryCache();
services.AddSession();
services.TryAddSingleton<IHttpContextAccessor, HttpContextAccessor>();
//services.AddScoped<Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration>();
services.AddMvc();
}
// This method gets called by the runtime. Use this method to configure the HTTP …Run Code Online (Sandbox Code Playgroud) 我在C#控制台应用程序中有以下代码:
string a = "1";
string b = a;
a = "2";
Console.WriteLine(b);
Run Code Online (Sandbox Code Playgroud)
我听说在C#中,字符串类型用作引用类型,但在上层代码中,变量b仍然显示1,为什么它不显示2!
c# ×6
asp.net ×2
asp.net-core ×2
odata ×2
api ×1
asp.net-mvc ×1
nlog ×1
swagger ×1
swagger-2.0 ×1