本文整理汇总了C#中IApplicationBuilder.UseDefaultFiles方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseDefaultFiles方法的具体用法?C# IApplicationBuilder.UseDefaultFiles怎么用?C# IApplicationBuilder.UseDefaultFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationBuilder
的用法示例。
在下文中一共展示了IApplicationBuilder.UseDefaultFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
// Configuration
var builder = new ConfigurationBuilder()
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
builder.AddEnvironmentVariables();
builder.Build();
// Logging
loggerFactory.AddDebug(minLevel: LogLevel.Verbose);
// Using different environments
if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase)) { }
// Middlewares
app.UseDeveloperExceptionPage();
app.UseRuntimeInfoPage(); // default path is /runtimeinfo
app.UseDefaultFiles();
app.UseStaticFiles();
// Web sockets
app.Map("/Managed", (appBuilder) => WebSocketsHelper.Configure(appBuilder, loggerFactory));
// IIS
app.UseIISPlatformHandler();
}
示例2: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseErrorPage();
app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll);
}
else
{
// Add Error handling middleware which catches all application specific errors and
// sends the request to the following path or controller action.
app.UseErrorHandler("/Home/Error");
}
// Serve the default file, if present.
app.UseDefaultFiles();
// Add static files to the request pipeline.
app.UseStaticFiles();
//app.Run(async (context) =>
//{
// await context.Response.WriteAsync("Hello World!");
//});
}
示例3: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if(env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
loggerFactory
.AddConsole(Configuration.GetSection("Logging"))
.AddDebug();
// Use the Default files ['index.html', 'index.htm', 'default.html', 'default.htm']
app.UseDefaultFiles()
.UseStaticFiles()
.UseIISPlatformHandler()
.UseMvc();
// Setup a generic Quotes API EndPoint
app.Map("/api/quotes", (config) =>
{
app.Run(async context =>
{
var quotes = "{ \"quotes\":" +
" [ { \"quote\": \"Duct tape is like the force. It has a light side, a dark side, and it holds the universe together.\", \"author\":\"Oprah Winfrey\"} ]" +
"}";
context.Response.ContentLength = quotes.Length;
context.Response.ContentType = "application/json";
await context.Response.WriteAsync(quotes);
});
});
}
示例4: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseDefaultFiles();
var contentTypeProvider = new FileExtensionContentTypeProvider();
contentTypeProvider.Mappings[".nzd"] = "application/octet-stream";
app.UseStaticFiles(new StaticFileOptions
{
ContentTypeProvider = contentTypeProvider
});
// At some stage we may want an MVC view for the home page, but at the moment
// we're just serving static files, so we don't need much.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action=Index}/{id?}");
});
}
示例5: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseCors("CorsPolicy");
app.UseDefaultFiles();
app.UseStaticFiles();
var tokenValidationParameters = CreateTokenValidationParameters();
app.UseJwtBearerAuthentication(new JwtBearerOptions
{
AutomaticAuthenticate = true,
AutomaticChallenge = true,
TokenValidationParameters = tokenValidationParameters
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "Default",
template: "api/{controller}/{action}/{id?}"
);
});
}
示例6: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app)
{
// Configure the HTTP request pipeline.
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
}
示例7: Configure
public void Configure(IApplicationBuilder app)
{
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
}
示例8: Configure
public void Configure(IApplicationBuilder app)
{
app.UseDefaultFiles();
app.UseStaticFiles();
var application = new CardApplication(new SocketServer());
application.Start();
}
示例9: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.Use(async (context, next) =>
{
await next();
if (context.Response.StatusCode == 404 && !Path.HasExtension(context.Request.Path.Value))
{
context.Request.Path = "/index.html"; // Put your Angular root page here
await next();
}
});
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
}
示例10: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app) {
app
.UseDefaultFiles()
.UseStaticFiles()
.UseDeveloperExceptionPage()
.UseMvc();
}
示例11: Configure
public void Configure(IApplicationBuilder app)
{
Log("WWWService Configure()");
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseMvc();
}
示例12: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseWebSockets();
app.UseDefaultFiles();
app.UseStaticFiles();
app.Map("/Preview/Socket", PreviewSocketHandler.Map);
app.Map("/Index/Socket", DashboardSocketHandler.Map);
app.Map("/SACNTransmitters/Socket", SACNTransmitterLive.Map);
app.Map("/OSCListeners/Socket", OSCListenerLive.Map);
app.Map("/RawDMX/Socket", RawDMXSocketHandler.Map);
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例13: Configure
public void Configure(IApplicationBuilder app)
{
// Initialise ReactJS.NET. Must be before static files.
app.UseReact(config =>
{
// If you want to use server-side rendering of React components,
// add all the necessary JavaScript files here. This includes
// your components as well as all of their dependencies.
// See http://reactjs.net/ for more information. Example:
//config
// .AddScript("~/Scripts/First.jsx")
// .AddScript("~/Scripts/Second.jsx");
// If you use an external build too (for example, Babel, Webpack,
// Browserify or Gulp), you can improve performance by disabling
// ReactJS.NET's version of Babel and loading the pre-transpiled
// scripts. Example:
//config
// .SetLoadBabel(false)
// .AddScriptWithoutTransform("~/Scripts/bundle.server.js");
});
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
//设定静态文件的默认文档
app.UseDefaultFiles(new DefaultFilesOptions()
{
DefaultFileNames = new string[] { "index.html", "index.htm" }
});
app.UseStaticFiles();
// Add MVC to the request pipeline.
app.UseMvc();
}
示例14: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler();
//app.UseMvc(ConfigureRoutes);
app.UseDefaultFiles();
app.UseStaticFiles();
//app.UseFileServer(enableDirectoryBrowsing: true);
//app.UseDirectoryBrowser();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
//template: "{controller=Workspace}/{action=WorkspaceHello}/{id?}");
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例15: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
//app.UseErrorPage(ErrorPageOptions.ShowAll);
}
else
{
// Add Error handling middleware which catches all application specific errors and
// send the request to the following path or controller action.
app.UseErrorHandler("/Home/Error");
}
// Add static files to the request pipeline.
app.UseStaticFiles();
app.UseDefaultFiles(new Microsoft.AspNet.StaticFiles.DefaultFilesOptions() { DefaultFileNames = new[] { "index.html" } });
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
// Uncomment the following line to add a route for porting Web API 2 controllers.
// routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}");
});
}