本文整理汇总了C#中IApplicationBuilder.UseReact方法的典型用法代码示例。如果您正苦于以下问题:C# IApplicationBuilder.UseReact方法的具体用法?C# IApplicationBuilder.UseReact怎么用?C# IApplicationBuilder.UseReact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IApplicationBuilder
的用法示例。
在下文中一共展示了IApplicationBuilder.UseReact方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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.UseStaticFiles();
// Add MVC to the request pipeline.
app.UseMvc();
}
示例2: Configure
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app)
{
app.UseDeveloperExceptionPage();
app.UseExceptionHandler("/home/error");
app.UseReact(config =>
{
config
.SetLoadBabel(false)
.AddScriptWithoutTransform("~/lib/generated/bundle.react.js");
});
app.UseStaticFiles();
app.UseFileServer();
app.UseMvc(routes =>
routes.MapRoute("Default",
"{controller=Home}/{action=Index}/{id?}")
);
app.Use(async (context, next) =>
{
if (context.Request.Path.Value.StartsWith("/hello"))
await context.Response.WriteAsync("Hello World!");
if (context.Request.Path.Value.StartsWith("/checkout"))
await context.Response.WriteAsync("Hello World!");
next();
});
}
示例3: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
{
// Add the console logger.
loggerfactory.AddConsole();
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
//app.UseBrowserLink();
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");
}
// 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
// .SetReuseJavaScriptEngines(true)
// .AddScript("~/js/Sample.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
.SetReuseJavaScriptEngines(true)
.SetLoadBabel(false)
.AddScriptWithoutTransform("~/js/bundle.server.js");
});
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "Comments",
template: "comments/page-{page}",
defaults: new { controller = "Home", action = "Comments", page = 1 }
);
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" }
);
});
}
示例4: Configure
public void Configure(IApplicationBuilder app)
{
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
app.UseStaticFiles();
app.UseMvcWithDefaultRoute();
app.UseReact(config => {
config.AddScript("~/scripts/templates.js");
});
}
示例5: 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");
}
//app.UseRequestServices();
app.UseReact(
config =>
{
// ES6 features are enabled by default. Uncomment the below line to disable them.
// See http://reactjs.net/guides/es6.html for more information.
//config.SetUseHarmony(false);
// Uncomment the below line if you are using Flow
// See http://reactjs.net/guides/flow.html for more information.
//config.SetStripTypes(true);
// 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("~/React/Hello.jsx");
//.AddScript("~/Scripts/Second.jsx");
});
// Add static files to the request pipeline.
app.UseStaticFiles();
// 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?}");
});
}
示例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(Configuration.GetSection("Logging"));
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
// 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");
config.AddScript("~/js/HelloWorld.jsx");
// config.AddScript("~/js/app.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");
});
app.UseStaticFiles();
// To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例7: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory)
{
// Configure the HTTP request pipeline.
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
// Add the console logger.
loggerfactory.AddConsole();
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
//app.UseBrowserLink();
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");
}
// Initialise ReactJS.NET. Must be before static files.
app.UseReact(config =>
{
config
.SetReuseJavaScriptEngines(true)
.AddScript("~/js/Sample.jsx");
});
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add MVC to the request pipeline.
app.UseMvc(routes =>
{
routes.MapRoute(
name: "Comments",
template: "comments/page-{page}",
defaults: new { controller = "Home", action = "Comments", page = 1 }
);
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" }
);
});
}
示例8: 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.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
// 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("~/js/remarkable.min.js")
.AddScript("~/js/tutorial.jsx")
.SetJsonSerializerSettings(new JsonSerializerSettings
{
StringEscapeHandling = StringEscapeHandling.EscapeHtml,
ContractResolver = new CamelCasePropertyNamesContractResolver()
});
// 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");
});
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例9: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseErrorPage();
loggerFactory.AddConsole(LogLevel.Information);
}
else
{
app.UseStatusCodePagesWithReExecute("/Error/Status{0}");
app.UseErrorHandler("/Error");
loggerFactory.AddConsole(LogLevel.Warning);
}
app.UseReact(config =>
{
config
.AddScript("~/Content/js/socialfeed.jsx")
.SetUseHarmony(true)
.SetReuseJavaScriptEngines(false);
});
app.UseStaticFiles();
app.UseIdentity();
app.UseSession();
// All real routes are defined using attributes.
app.UseMvcWithDefaultRoute();
// Don't fall back to IIS on 404.
// TODO: This won't be needed from beta7 onwards: https://github.com/aspnet/Announcements/issues/54
app.Run(context =>
{
context.Response.StatusCode = 404;
return Task.FromResult(0);
});
// This is really not ideal, need to figure out a better way to do this.
// Based off http://stackoverflow.com/a/30762664/210370
UrlHelperExtensions.HttpContextAccessor = app.ApplicationServices.GetRequiredService<IHttpContextAccessor>();
}
示例10: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
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.UseExceptionHandler("/Home/Error");
}
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
// 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");
});
//Configure SignalR
app.UseSignalR();
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline.
app.UseIdentity();
// Add and configure the options for authentication middleware to the request pipeline.
// You can add options for middleware as shown below.
// For more information see http://go.microsoft.com/fwlink/?LinkID=532715
//app.UseFacebookAuthentication(options =>
//{
// options.AppId = Configuration["Authentication:Facebook:AppId"];
// options.AppSecret = Configuration["Authentication:Facebook:AppSecret"];
//});
//app.UseGoogleAuthentication(options =>
//{
// options.ClientId = Configuration["Authentication:Google:ClientId"];
// options.ClientSecret = Configuration["Authentication:Google:ClientSecret"];
//});
//app.UseMicrosoftAccountAuthentication(options =>
//{
// options.ClientId = Configuration["Authentication:MicrosoftAccount:ClientId"];
// options.ClientSecret = Configuration["Authentication:MicrosoftAccount:ClientSecret"];
//});
//app.UseTwitterAuthentication(options =>
//{
// options.ConsumerKey = Configuration["Authentication:Twitter:ConsumerKey"];
// options.ConsumerSecret = Configuration["Authentication:Twitter:ConsumerSecret"];
//});
// 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?}");
});
}
示例11: Configure
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddDebug();
if (env.IsDevelopment())
{
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
loggerFactory.AddConsole(LogLevel.Information);
}
else
{
app.UseStatusCodePagesWithReExecute("/Error/Status{0}");
app.UseExceptionHandler("/Error");
loggerFactory.AddConsole(LogLevel.Warning);
}
app.UseReact(config =>
{
config
.AddScript("~/Content/js/socialfeed.jsx")
.SetReuseJavaScriptEngines(false);
});
app.UseStaticFiles();
app.UseIdentity();
app.UseSession();
// All real routes are defined using attributes.
app.UseMvcWithDefaultRoute();
// This is really not ideal, need to figure out a better way to do this.
// Based off http://stackoverflow.com/a/30762664/210370
UrlHelperExtensions.HttpContextAccessor = app.ApplicationServices.GetRequiredService<IHttpContextAccessor>();
}
示例12: Configure
// Configure is called after ConfigureServices is called.
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.MinimumLevel = LogLevel.Information;
loggerFactory.AddConsole();
loggerFactory.AddDebug();
// Configure the HTTP request pipeline.
// Add the following to the request pipeline only in development environment.
if (env.IsDevelopment())
{
app.UseBrowserLink();
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");
}
// Add the platform handler to the request pipeline.
app.UseIISPlatformHandler();
// 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 static files to the request pipeline.
app.UseStaticFiles();
// 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?}");
});
}
示例13: 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();
app.UseApplicationInsightsRequestTelemetry();
if (env.IsDevelopment()) {
app.UseBrowserLink();
app.UseDeveloperExceptionPage();
app.UseDatabaseErrorPage();
}
else {
app.UseExceptionHandler("/Home/Error");
// For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
try {
using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
.CreateScope()) {
serviceScope.ServiceProvider.GetService<BookNoteContext>()
.Database.Migrate();
}
}
catch { }
}
app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
app.UseApplicationInsightsExceptionTelemetry();
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");
});
app.UseStaticFiles();
app.UseIdentity();
// To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715
app.UseMvc(routes => {
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
示例14: 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);
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");
}
// Initialise ReactJS.NET. Must be before static files.
app.UseReact(config =>
{
config
.SetUseHarmony(true)
.SetReuseJavaScriptEngines(true)
.SetStripTypes(true)
.AddScript("~/js/login.jsx");
});
// Add static files to the request pipeline.
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline.
app.UseIdentity();
// Add authentication middleware to the request pipeline. You can configure options such as Id and Secret in the ConfigureServices method.
// For more information see http://go.microsoft.com/fwlink/?LinkID=532715
// app.UseFacebookAuthentication();
// app.UseGoogleAuthentication();
// app.UseMicrosoftAccountAuthentication();
// app.UseTwitterAuthentication();
// 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?}");
routes.MapRoute(
name: "SeachPage",
template: "{controller=Home}/{action=Index}/{id}/{page?}/{pagesize?}");
});
// Add Initialization Data
ActivatorUtilities.CreateInstance<DBInitData>(app.ApplicationServices)
.InitializeData();
}