本文整理汇总了C#中IBuilder.UseMvc方法的典型用法代码示例。如果您正苦于以下问题:C# IBuilder.UseMvc方法的具体用法?C# IBuilder.UseMvc怎么用?C# IBuilder.UseMvc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IBuilder
的用法示例。
在下文中一共展示了IBuilder.UseMvc方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
public void Configure(IBuilder app)
{
// Setup configuration sources
var configuration = new Configuration();
configuration.AddJsonFile("config.json");
configuration.AddEnvironmentVariables();
// Set up application services
app.UseServices(services =>
{
// Add MVC services to the services container
services.AddMvc();
});
// Add static files to the request pipeline
app.UseStaticFiles();
// Add MVC to the request pipeline
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
routes.MapRoute(
name: "api",
template: "{controller}/{id?}");
});
}
示例2: Configure
public void Configure(IBuilder app)
{
var configuration = app.GetTestConfiguration();
// Set up application services
app.UseServices(services =>
{
// Add MVC services to the services container
services.AddMvc(configuration);
services.AddSingleton<INestedProvider<ActionDescriptorProviderContext>, ActionDescriptorCreationCounter>();
});
// Add MVC to the request pipeline
app.UseMvc(routes =>
{
routes.MapRoute("areaRoute",
"{area:exists}/{controller}/{action}",
new { controller = "Home", action = "Index" });
routes.MapRoute("ActionAsMethod", "{controller}/{action}",
defaults: new { controller = "Home", action = "Index" });
});
}
示例3: Configure
public void Configure(IBuilder app)
{
// Setup configuration sources
var configuration = new Configuration();
configuration.AddEnvironmentVariables();
app.UseOwin();
// Set up application services
app.UseServices(services =>
{ // Add MVC services to the services container
services.AddMvc();
services.SetupOptions<MvcOptions>(options => {
System.Diagnostics.Debug.WriteLine(options.OutputFormatters.Select(item => item.GetType().Name));
options.OutputFormatters.RemoveAt(0);
});
});
// Add static files to the request pipeline
app.UseStaticFiles();
// Add MVC to the request pipeline
app.UseMvc(routes =>
{
//routes.MapRoute(
// name: "default",
// template: "{controller}/{action}/{id?}",
// defaults: new { controller = "Home", action = "Index" });
routes.MapRoute(
name: "api",
template: "{controller}/{id?}");
});
}
示例4: Configure
public void Configure(IBuilder app)
{
app.UseServices(services =>
{
/* Adding IConfiguration as a service in the IoC to avoid instantiating Configuration again.
* Below code demonstrates usage of multiple configuration sources. For instance a setting say 'setting1' is found in both the registered sources,
* then the later source will win. By this way a Local config can be overridden by a different setting while deployed remotely.
*/
var configuration = new Configuration();
configuration.AddJsonFile("LocalConfig.json");
configuration.AddEnvironmentVariables(); //All environment variables in the process's context flow in as configuration values.
services.AddInstance<IConfiguration>(configuration);
//Add all MVC related services to IoC.
services.AddMvc();
/*Add all EF related services to IoC.*/
services.AddEntityFramework().AddSqlServer();
services.AddTransient<MusicStoreContext>();
//Add all Identity related services to IoC.
services.AddTransient<DbContext, ApplicationDbContext>();
services.AddIdentity<ApplicationUser, IdentityRole>(s =>
{
s.AddEntity();
});
services.AddTransient<SignInManager<ApplicationUser>>();
});
/* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
* Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
*/
app.UseErrorPage(ErrorPageOptions.ShowAll);
//Serves static files in the application.
app.UseFileServer();
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
});
app.UseMvc(routes =>
{
routes.MapRoute(
null,
"{controller}/{action}",
new { controller = "Home", action = "Index" });
});
//Populates the MusicStore sample data
SampleData.InitializeMusicStoreDatabaseAsync(app.ApplicationServices).Wait();
SampleData.InitializeIdentityDatabaseAsync(app.ApplicationServices).Wait();
//Creates a Store manager user who can manage the store.
CreateAdminUser(app.ApplicationServices).Wait();
}
示例5: Configure
public void Configure(IBuilder app)
{
// Enable Browser Link support
app.UseBrowserLink();
// Setup configuration sources
var configuration = new Configuration();
configuration.AddJsonFile("config.json");
configuration.AddEnvironmentVariables();
// Set up application services
app.UseServices(services =>
{
// Add EF services to the services container
services.AddEntityFramework()
.AddSqlServer();
// Configure DbContext
services.SetupOptions<DbContextOptions>(options =>
{
options.UseSqlServer(configuration.Get("Data:DefaultConnection:ConnectionString"));
});
// Add Identity services to the services container
services.AddIdentity<ApplicationUser>()
.AddEntityFramework<ApplicationUser, ApplicationDbContext>()
.AddHttpSignIn();
// Add MVC services to the services container
services.AddMvc();
});
// Add static files to the request pipeline
app.UseStaticFiles();
// Add cookie-based authentication to the request pipeline
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
});
// Add MVC to the request pipeline
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
routes.MapRoute(
name: "api",
template: "{controller}/{id?}");
});
}
示例6: Configure
public void Configure(IBuilder app)
{
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
app.UseServices(services =>
{
services.AddMvc();
});
// Add static files to the request pipeline
app.UseStaticFiles();
app.UseMvc();
}
示例7: Configure
public void Configure(IBuilder builder)
{
builder.UseErrorPage();
builder.UseServices(s => {
s.AddMvc();
});
builder.UseMvc();
builder.UseWelcomePage();
}
示例8: Configure
public void Configure(IBuilder app)
{
// Enable Browser Link support
app.UseBrowserLink();
// Setup configuration sources
var configuration = new Configuration();
//configuration.AddIniFile("config.ini");
configuration.AddJsonFile("config.json");
configuration.AddEnvironmentVariables();
//app.Run(async context =>
//{
// await context.Response.WriteAsync(configuration.Get("Data:Configuration"));
//});
app.Run(async context =>
{
var asm = Assembly.Load(new AssemblyName("klr.host"));
var assemblyVersion = asm.GetCustomAttribute<AssemblyInformationalVersionAttribute>();
await context.Response.WriteAsync(assemblyVersion.InformationalVersion);
});
// Set up application services
app.UseServices(services =>
{
// Add EF services to the services container
services.AddEntityFramework().AddInMemoryStore();
services.AddScoped<PersonContext>();
// Add MVC services to the services container
services.AddMvc();
});
// Add static files to the request pipeline
app.UseStaticFiles();
// Add MVC to the request pipeline
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
routes.MapRoute(
name: "api",
template: "{controller}/{id?}");
});
}
示例9: Configure
public void Configure(IBuilder app)
{
app.UseServices(services =>
{
services.AddMvc();
});
app.UseMvc(routes =>
{
routes.MapRoute("ApiRoute", "{controller}/{id?}");
});
}
示例10: Configure
public void Configure(IBuilder app)
{
app.UseErrorPage();
app.UseServices(services =>
{
services.AddMvc();
});
app.UseMvc();
app.UseWelcomePage();
}
示例11: Configure
public void Configure(IBuilder app)
{
app.UseServices(services =>
{
services.AddMvc();
});
app.UseStaticFiles();
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller}/{action}/{id?}",
defaults: new { controller = "Home", action = "Index" });
});
}
示例12: Configure
public void Configure(IBuilder app)
{
BasicConfigurator.Configure();
LogEvent.Startup.Log(this, "Starting up application");
app.UseErrorPage();
app.UseServices(services =>
{
services.AddMvc();
});
app.UseMvc();
app.UseWelcomePage();
}
示例13: Configure
public void Configure(IBuilder app)
{
/* Error page middleware displays a nice formatted HTML page for any unhandled exceptions in the request pipeline.
* Note: ErrorPageOptions.ShowAll to be used only at development time. Not recommended for production.
*/
app.UseErrorPage(ErrorPageOptions.ShowAll);
app.UseServices(services =>
{
//Add all MVC related services to IoC.
services.AddMvc();
//Add all SignalR related services to IoC.
services.AddSignalR();
});
//Configure SignalR
app.UseSignalR();
//Serves static files in the application.
app.UseFileServer();
//Configure WebFx
app.UseMvc(routes =>
{
routes.MapRoute(
null,
"{controller}/{action}",
new { controller = "Home", action = "Index" });
routes.MapRoute(
null,
"api/{controller}/{action}",
new { controller = "Home", action = "Index" });
routes.MapRoute(
null,
"api/{controller}",
new { controller = "Home" });
});
}
示例14: Configure
public void Configure(IBuilder app)
{
var configuration = new Configuration();
configuration.AddEnvironmentVariables();
// Set up application services
app.UseServices(services =>
{
services.Add(OptionsServices.GetDefaultServices());
services.SetupOptions<BlobStorageOptions>(options =>
{
options.ConnectionString = configuration.Get("ReversePackageSearch:BlobStorageConnection");
});
// Add MVC services to the services container
services.AddMvc();
});
// Add static files
app.UseStaticFiles(new StaticFileOptions { FileSystem = new PhysicalFileSystem("content") });
// Add MVC to the request pipeline
app.UseMvc();
}
示例15: Configure
public void Configure(IBuilder app)
{
app.UseServices(services =>
{
services.AddMvc();
});
app.Use(async (context, next) =>
{
Console.WriteLine(context.Request.Path);
try
{
await next();
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
});
app.UseMvc();
}