本文整理汇总了C#中IApplicationBuilder.UseWebpackDevMiddleware方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseWebpackDevMiddleware方法的具体用法?C# IApplicationBuilder.UseWebpackDevMiddleware怎么用?C# IApplicationBuilder.UseWebpackDevMiddleware使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationBuilder
的用法示例。
在下文中一共展示了IApplicationBuilder.UseWebpackDevMiddleware方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true
});
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
}
示例2: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Warning;
loggerFactory.AddConsole();
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
// Add Error handling middleware which catches all application specific errors and
// send the request to the following path or controller action.
app.UseExceptionHandler("/Home/Error");
}
// In dev mode, the JS/TS/etc is compiled and served dynamically and supports hot replacement.
// In production, we assume you've used webpack to emit the prebuilt content to disk.
if (env.IsDevelopment()) {
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true,
ReactHotModuleReplacement = true
});
}
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapSpaFallbackRoute(
name: "default",
defaults: new { controller="Home", action = "Index" });
});
}
示例3: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env)
{
app.UseDeveloperExceptionPage();
// For real apps, you should only use Webpack Dev Middleware at development time. For production,
// you'll get better performance and reliability if you precompile the webpack output and simply
// serve the resulting static files. For examples of setting up this automatic switch between
// development-style and production-style webpack usage, see the 'templates' dir in this repo.
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true
});
app.UseStaticFiles();
loggerFactory.AddConsole();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例4: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory, IHostingEnvironment env)
{
app.UseDeveloperExceptionPage();
// Initialize the sample data
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
// In dev mode, the JS/TS/etc is compiled and served dynamically and supports hot replacement.
// In production, we assume you've used webpack to emit the prebuilt content to disk.
if (env.IsDevelopment()) {
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true,
ReactHotModuleReplacement = true
});
}
app.UseStaticFiles();
loggerFactory.AddConsole();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
// Matches requests that correspond to an existent controller/action pair
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
// Matches any other request that doesn't appear to have a filename extension (defined as 'having a dot in the last URI segment').
// This means you'll correctly get 404s for /some/dir/non-existent-image.png instead of returning the SPA HTML.
// However, it means requests like /customers/isaac.newton will *not* be mapped into the SPA, so if you need to accept
// URIs like that you'll need to match all URIs, e.g.:
// routes.MapRoute("spa-fallback", "{*anything}", new { controller = "Home", action = "Index" });
// (which of course will match /customers/isaac.png too, so in that case it would serve the PNG image at that URL if one is on disk,
// or the SPA HTML if not).
routes.MapSpaFallbackRoute("spa-fallback", new { controller = "Home", action = "Index" });
});
}
示例5: Configure
/// <summary>
/// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
/// </summary>
/// <param name="app"></param>
/// <param name="env"></param>
/// <param name="loggerFactory"></param>
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
app.UseBrowserLink();
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions()
{
HotModuleReplacement = true
});
app.UseSwagger(documentFilter: (swaggerDoc, httpRequest) =>
{
swaggerDoc.Host = httpRequest.Host.Value;
});
app.UseSwaggerUi(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "V1 Docs");
c.ConfigureOAuth2("test-client-id123", "test-client-secr43et", "test-rea32lm", "test-a11pp");
}
);
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseCors("MyPolicy");
//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();
// }
//});
//var angularRoutes = new[] {
// "/api",
// "/connect"
// };
//app.Use(async (context, next) =>
//{
// if (context.Request.Path.HasValue && null == angularRoutes.FirstOrDefault(
// (ar) => context.Request.Path.Value.StartsWith(ar, StringComparison.OrdinalIgnoreCase)))
// {
// context.Request.Path = new PathString("/");
// }
// await next();
//});
app.UseDefaultFiles();
app.UseStaticFiles();
app.UseIdentity();
app.UseOAuthValidation();
app.UseOpenIddict();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new {controller = "Home", action = "Index"});
});
//builder =>
//{
//builder.AllowAnyHeader().AllowAnyMethod().AllowAnyOrigin();
//});
}
示例6: 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(LogLevel.Warning);
// Initialize the sample data
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
if (env.IsDevelopment()) {
app.UseDeveloperExceptionPage();
} else {
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler();
// In dev mode, the JS/TS/etc is compiled and served dynamically and supports hot replacement.
// In production, we assume you've used webpack to emit the prebuilt content to disk.
if (env.IsDevelopment()) {
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true,
ReactHotModuleReplacement = true
});
}
app.UseStaticFiles();
app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
routes.MapSpaFallbackRoute(
name: "spa-fallback",
defaults: new { controller = "Home", action = "Index" });
});
}