本文整理汇总了C#中System.Web.Mvc类的典型用法代码示例。如果您正苦于以下问题:C# System.Web.Mvc类的具体用法?C# System.Web.Mvc怎么用?C# System.Web.Mvc使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
System.Web.Mvc类属于命名空间,在下文中一共展示了System.Web.Mvc类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SetupRazor
/* Eliminated all vbhtml and aspx, and unused locations, and engines*/
private static void SetupRazor()
{
ViewEngines.Engines.Clear();
var razor = new PrecompiledMvcEngine(typeof(Mvc).Assembly)
{
UsePhysicalViewsIfNewer = true
};
ViewEngines.Engines.Insert(0, razor);
// StartPage lookups are done by WebPages.
VirtualPathFactoryManager.RegisterVirtualPathFactory(razor);
// Not using areas, not using vbhtmls.
var areaViewLocations = new string[0];
var viewLocations = new[] { "~/Views/{1}/{0}.cshtml", "~/Views/Shared/{0}.cshtml" };
razor.AreaMasterLocationFormats = areaViewLocations;
razor.AreaPartialViewLocationFormats = areaViewLocations;
razor.AreaViewLocationFormats = areaViewLocations;
razor.MasterLocationFormats = viewLocations;
razor.PartialViewLocationFormats = viewLocations;
razor.ViewLocationFormats = viewLocations;
ViewEngines.Engines.Add(razor);
}
开发者ID:chandru9279,项目名称:zasz.me,代码行数:26,代码来源:Mvc.cs
示例2: Initialize
public static void Initialize()
{
if (_initialized)
return;
var namespaces = new[] { "HipChat.Widget.Mvc" };
var routes = RouteTable.Routes;
var hipChatWidgetRoute = Settings.Route;
routes.MapRoute(
"HipChat.Widget.Mvc",
string.Format("{0}/{{resource}}", hipChatWidgetRoute),
new
{
controller = "HipChatWidget",
action = "Chat",
resource = UrlParameter.Optional
},
null,
namespaces);
if (hipChatWidgetRoute != "HipChatWidget" && Settings.IgnoreDefaultRoute)
{
routes.IgnoreRoute("HipChatWidget");
routes.IgnoreRoute("HipChatWidget/{*pathinfo}");
}
_initialized = true;
}
开发者ID:jdehlin,项目名称:HipChat-Widget-MVC,代码行数:30,代码来源:Bootstrapper.cs
示例3: RegisterArea
public override void RegisterArea(AreaRegistrationContext context)
{
RegisterIoc();
var ns = new[] { "MvcSolution.Web.Admin.Controllers.*" };
var defaults = new {controller = "home", action = "index", id = UrlParameter.Optional};
context.Map("admin/{controller}/{action}/{id}", defaults, ns);
}
开发者ID:dut3062796s,项目名称:mvcsolution,代码行数:8,代码来源:AdminAreaRegistration.cs
示例4: RegisterRoutes
protected override void RegisterRoutes(RouteCollection routes)
{
var defaults = new { controller = "home", action = "index", id = UrlParameter.Optional };
var ns = new[] { "MvcSolution.Web.Public.Controllers.*" };
routes.Map("{controller}/{action}/{id}", defaults, ns);
}
开发者ID:dut3062796s,项目名称:mvcsolution,代码行数:8,代码来源:Global.asax.cs
示例5: RegisterArea
public override void RegisterArea(AreaRegistrationContext context)
{
Ioc.RegisterInheritedTypes(typeof(Services.Admin.IUserService).Assembly, typeof(ServiceBase));
var ns = new[] { "MvcSolution.Web.Admin.Controllers.*" };
context.Map("admin", "user", "index", ns);
context.Map("admin/{controller}/{action}/{id}", new { controller = "home", action = "index", id = UrlParameter.Optional }, ns);
}
开发者ID:yuandong618,项目名称:mvcsolution,代码行数:9,代码来源:AdminAreaRegistration.cs
示例6: RegisterArea
public override void RegisterArea(AreaRegistrationContext context)
{
RegisterIoc();
var ns = new[] { "MvcSolution.Web.Public.Controllers.*" };
context.Map("logout", "account", "logout", ns);
context.Map("login", "account", "login", ns);
context.Map("register", "account", "register", ns);
}
开发者ID:dut3062796s,项目名称:mvcsolution,代码行数:9,代码来源:PublicAreaRegistration.cs
示例7: Index
public ActionResult Index()
{
var movies = new[] {
new Movie {
Title = "The Big Lebowski",
ReleaseDate = "1998",
RunningTime = "117 mins",
Actors = new[] {
new Actor("Jeff Bridges"),
new Actor("John Goodman"),
new Actor("Steve Buscemi"),
}
},
new Movie {
Title = "The Princess Bride",
ReleaseDate = "1987",
RunningTime = "98 mins",
Actors = new[] {
new Actor("Cary Elwes"),
new Actor("Many Patinkin"),
new Actor("Robin Wright"),
}
},
};
return View(movies);
}
开发者ID:hoborg91,项目名称:RazorClientTemplates,代码行数:27,代码来源:HomeController.cs
示例8: ResetDatabase
public ActionResult ResetDatabase(FormCollection form)
{
NHibernateBootstrapper.CreateSchema();
using (var session = NHibernateBootstrapper.GetSession())
{
var users = new[]
{
Core.Domain.User.CreateNewUser("[email protected]", "admin"),
Core.Domain.User.CreateNewUser("[email protected]", "user")
};
users.ForEach(u => session.Save(u));
var project = Project.Create("Fail Tracker", users[0]);
session.Save(project);
(new[] {
Issue.CreateNewIssue(project, "Project support", users[0], "As someone who manages many software projects, I want to be able to organize issues and bugs into projects within Fail Tracker.")
.ReassignTo(users[0])
.ChangeSizeTo(PointSize.Eight),
Issue.CreateNewIssue(project, "Site rendering problems in IE6", users[1], "The site does not render the same in al versions of IE!")
.ChangeTypeTo(IssueType.Bug)
.ChangeSizeTo(PointSize.OneHundred)
.ReassignTo(users[1]),
Issue.CreateNewIssue(project, "Enable user invite", users[0], "I want to be able to invite users to join Fail Tracker through a form on the site.")
.ReassignTo(users[0])
.ChangeSizeTo(PointSize.Five),
Issue.CreateNewIssue(project, "Support unassigned stories", users[0], "I want to be able to leave stories and bugs unassigned.")
.ChangeSizeTo(PointSize.Five),
}).ForEach(i => session.Save(i));
session.Flush();
}
return this.RedirectToAction<DashboardController>(c => c.Index());
}
开发者ID:rajeshpillai,项目名称:Fail-Tracker,代码行数:35,代码来源:UtilityController.cs
示例9: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
// Local variable of an array of strings that contains the namespace
// of wherever our PostsController namespace exists. When namespaces is
// passed into the routes below, they'll be targeting a specific folder.
// This is done to avoid conflicts as more than one PostsController exist.
var namespaces = new[] { typeof(PostsController).Namespace };
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("Login", "login", new { controller = "Auth", action = "Login" }, namespaces);
routes.MapRoute("Logout", "logout", new { controller = "Auth", action = "Logout" }, namespaces);
routes.MapRoute("Home", "", new { controller = "Posts", action = "Index" }, namespaces);
// The default route will not be used.
// All routes in this application will be explicit, which
// allows the developer to have more control.
//routes.MapRoute(
// name: "Default",
// url: "{controller}/{action}/{id}",
// defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
//);
}
开发者ID:jimxshaw,项目名称:samples-csharp,代码行数:26,代码来源:RouteConfig.cs
示例10: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
var namespaces = new[] { "Branch.App.Controllers" };
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
AreaRegistration.RegisterAllAreas();
// Welcome
routes.MapRoute("Welcome", "Home/",
new { controller = "Home", action = "Index" }, namespaces);
// Blog
routes.MapRoute("Blog", "Blog/View/{slug}",
new { controller = "Blog", action = "View", slug = "welcome" }, namespaces);
// Search
routes.MapRoute("SearchIdentity", "Search/Identity/{ident}",
new { controller = "Search", action = "Identity", ident = UrlParameter.Optional }, namespaces);
routes.MapRoute("Search", "Search/",
new { controller = "Search", action = "Index" }, namespaces);
// Catch All
routes.MapRoute("Default", "{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional }, namespaces);
}
开发者ID:tamilselvamr,项目名称:branch,代码行数:26,代码来源:RouteConfig.cs
示例11: MoreVehicles
public ActionResult MoreVehicles()
{
var vehicles = new[]
{
new Vehicle
{
Name = "1968 Pontiac Firebird",
Type = "Classic Car",
Price = 27499.99m,
Components = new[]
{
new Component {Name = "8 cyl. Engine", Color = "Red"},
new Component {Name = "Interiors", Color = "Cameo Ivory"},
new Component {Name = "Exteriors", Color = "Autumn Bronze"}
}
},
new Vehicle
{
Name = "WW-II Seehund U-Boat",
Type = "German Midget Submarine",
Price = 2579000m,
Components = new[]
{
new Component {Name = "Torpedo", Color = "Gray"},
new Component {Name = "Torpedo", Color = "Gray"},
new Component {Name = "Torpedo", Color = "Gray"},
new Component {Name = "Torpedo", Color = "Black"},
}
},
};
return Json(vehicles, JsonRequestBehavior.AllowGet);
}
开发者ID:bevacqua,项目名称:Razor.Js,代码行数:32,代码来源:HomeController.cs
示例12: Index
public ActionResult Index()
{
Vehicle[] vehicles = new[]
{
new Vehicle
{
Name = "Schinn Fixed Bicycle",
Type = "Bicycle",
Price = 199.99m,
Components = new[]
{
new Component {Name = "Speed Gauge", Color = "Red"},
new Component {Name = "Pedal", Color = "Black"},
new Component {Name = "Big Wheel", Color = "Dark Red"}
}
},
new Vehicle
{
Name = "Predator",
Type = "Fighter Drone",
Price = 1650000.99m,
Components = new[]
{
new Component {Name = "Autopilot", Color = "None"},
new Component {Name = "Missile Battery", Color = "Black"},
}
},
};
return View(vehicles);
}
开发者ID:bevacqua,项目名称:Razor.Js,代码行数:30,代码来源:HomeController.cs
示例13: PreviewBriefArticle
public ActionResult PreviewBriefArticle(int articleId)
{
var articles = new[] {
articlesService.GetById(articleId)
};
return View("~/Views/Articles/Articles.cshtml", articles);
}
开发者ID:kidaa,项目名称:Indigo,代码行数:7,代码来源:ArticlesController.cs
示例14: RegisterRoutes
public static void RegisterRoutes(RouteCollection routes)
{
var namespaces = new[] {typeof (PostsController).Namespace};
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("TagForRealThisTime", "tag/{idAndSlug}", new { controller = "Posts", action = "Tag" },
namespaces);
routes.MapRoute("Tag", "tag/{id}-{slug}", new { controller = "Posts", action = "Tag" }, namespaces);
routes.MapRoute("PostForRealThisTime", "post/{idAndSlug}", new {controller = "Posts", action = "Show"},
namespaces);
routes.MapRoute("Post", "post/{id}-{slug}", new { controller = "Posts", action = "Show" }, namespaces);
routes.MapRoute("Login", "login", new {controller = "Auth", action = "Login"}, namespaces);
routes.MapRoute("Logout", "logout", new { controller = "Auth", action = "Logout" }, namespaces);
//empty route "" means the one that shows up when nothing is specified
routes.MapRoute("Home", "", new { controller = "Posts", action = "index" }, namespaces);
routes.MapRoute("Sidebar", "", new { controller = "Layout", action = "Sidebar" }, namespaces);
routes.MapRoute("Error500", "errors/500", new {controller="Errors", action="Error"}, namespaces);
routes.MapRoute("Error404", "errors/404", new {controller="Errors", action="NotFound"}, namespaces);
}
开发者ID:JordanDTaylor,项目名称:SimpleBlog,代码行数:25,代码来源:RouteConfig.cs
示例15: CreateActionResultWithObjectReturnsSomethingElse
public void CreateActionResultWithObjectReturnsSomethingElse()
{
var actionDescriptor = MockRepository.GenerateStub<ActionDescriptor>();
object actionReturnValue = new {};
var actionResult = _actionInvoker.CreateActionResult(null, actionDescriptor, actionReturnValue);
Assert.That(actionResult, Is.Not.EqualTo(actionReturnValue));
}
开发者ID:bnathyuw,项目名称:Restful-Simple-MVC,代码行数:7,代码来源:RestfulActionInvokerTests.cs
示例16: CustomRazorViewEngine
public CustomRazorViewEngine()
{
var viewLocations = new[]
{
"~/Views/{0}.cshtml",
"~/Views/{1}/{0}.cshtml",
"~/Views/Menu/{0}.cshtml",
//"~/Views/Carlos/{1}/{0}.cshtml",
//"~/Views/Carlos/Shared/{0}.cshtml",
};
this.ViewLocationFormats = viewLocations;
this.PartialViewLocationFormats = viewLocations;
#region AREAs
//var areaViewLocations = new[]
//{
// "~/Views/Carlos/{1}/{0}.cshtml",
// "~/Views/Carlos/Shared/{0}.cshtml",
// "~/Views/{2}/{1}/{0}.cshtml", // Coping with Area's
// "~/Views/{2}/Shared/{0}.cshtml"
//};
//this.AreaPartialViewLocationFormats = areaViewLocations;
//this.AreaViewLocationFormats = areaViewLocations;
#endregion
}
开发者ID:sabor413,项目名称:sc80wffmex,代码行数:26,代码来源:CustomRazorWebEngine.cs
示例17: MoreMovies
public ActionResult MoreMovies()
{
var movies = new[] {
new Movie {
Title = "Rounders",
ReleaseDate = "1998",
RunningTime = "121 mins",
Actors = new[] {
new Actor("Matt Damon"),
new Actor("Edward Norton"),
new Actor("John Malcovich"),
}
},
new Movie {
Title = "Batman",
ReleaseDate = "1989",
RunningTime = "126 mins",
Actors = new[] {
new Actor("Michael Keaton"),
new Actor("Jack Nicholson"),
}
},
};
return Json(movies, JsonRequestBehavior.AllowGet);
}
开发者ID:hoborg91,项目名称:RazorClientTemplates,代码行数:26,代码来源:HomeController.cs
示例18: PasswordModelBinderShouldReturnValuesForSpecifiedQueryStrings
public void PasswordModelBinderShouldReturnValuesForSpecifiedQueryStrings()
{
var viewContext = new ViewContext();
viewContext.HttpContext = MockHttpContext.FakeHttpContext();
var appraisalCompanyAdminManagement = Substitute.For<IAppraiserManagement>();
var appraisalCompanyWizardService = Substitute.For<IAppraisalCompanyService>();
var controller = new AppraisalCompanyFeesController(appraisalCompanyWizardService, appraisalCompanyAdminManagement);
controller.SetFakeControllerContext(viewContext.HttpContext);
NameValueCollection queryString = new NameValueCollection();
controller.HttpContext.Request.QueryString.Returns(queryString);
PasswordModelBinder target = new PasswordModelBinder();
var testCases = new[] {
new {QueryStringParameterName="UserChangePasswordViewModel.NewPassword",Value="17"},
new {QueryStringParameterName="CreateUserGeneralInfoViewModel.Password",Value="42"},
new {QueryStringParameterName="Password",Value="2"},
new {QueryStringParameterName="NewPassword",Value="33"},
new {QueryStringParameterName="AppraisalCompanyAdmin.Password",Value="asd"},
new {QueryStringParameterName="GeneralInfo.Password",Value="sssssssssss"},
};
//act
foreach (var testCase in testCases)
{
queryString.Add(testCase.QueryStringParameterName, testCase.Value);
string result = (string)target.BindModel(controller.ControllerContext, new ModelBindingContext());
result.Should().BeEquivalentTo(testCase.Value);
queryString.Remove(testCase.QueryStringParameterName);
}
}
开发者ID:evkap,项目名称:DVS,代码行数:33,代码来源:PasswordModelBinderTest.cs
示例19: Index
public ActionResult Index()
{
ViewBag.Title = "Home Page test";
var data = new {firstname = "test", lastname = "lastname"};
string json = JsonConvert.SerializeObject(data);
return View();
}
开发者ID:jezzay,项目名称:Test-Travis-CI,代码行数:8,代码来源:HomeController.cs
示例20: Index
public ActionResult Index()
{
ViewData["Message"] = "Welcome to ASP.NET MVC!";
var model = new[] {new Person("John"), new Person("Jack"), new Person("Jill")};
return new ResultHandledByCodecResult(model);
}
开发者ID:mwagg,项目名称:guerillatactics,代码行数:8,代码来源:HomeController.cs
注:本文中的System.Web.Mvc类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论