yavsc/web/Global.asax.cs
Paul Schneider b918d9ff03 * Makefile: target set clarified
* Profile.aspx:
* AccountController.cs: Fixes the avatar display at edition time.

* style.css:
* UserPost.aspx: the users avatar as the page logo, floating at left

* Web.config:
* Global.asax.cs: Uses a new application parameter named
  "DefaultController", usage defaulting to "Blogs".

* Web.csproj:
* web.config: 

* Profile.cs: Fixes a default blog title using a null user's full name
2015-04-23 04:39:34 +02:00

111 lines
3.1 KiB
C#
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using Yavsc.Formatters;
using Yavsc.Model.FrontOffice;
using System.Web.SessionState;
using System.Web.Mvc;
using System.Web.Http;
using System.Web.WebPages.Scope;
using System.Reflection;
using System.Web.Configuration;
namespace Yavsc
{
/// <summary>
/// Mvc application.
/// </summary>
public class MvcApplication : System.Web.HttpApplication
{
/// <summary>
/// Registers the routes.
/// </summary>
/// <param name="routes">Routes.</param>
public static void RegisterRoutes (RouteCollection routes)
{
// Should be FrontOffice
string defaultController = WebConfigurationManager.AppSettings ["DefaultController"];
if (defaultController == null)
{
defaultController = "Admin";
}
routes.IgnoreRoute ("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute ("Scripts/{*pathInfo}");
routes.IgnoreRoute ("Theme/{*pathInfo}");
routes.IgnoreRoute ("images/{*pathInfo}");
routes.IgnoreRoute ("users/{*pathInfo}");
routes.IgnoreRoute ("files/{*pathInfo}");
routes.IgnoreRoute ("avatars/{*pathInfo}");
routes.IgnoreRoute ("xmldoc/{*pathInfo}"); // xml doc
routes.IgnoreRoute ("htmldoc/{*pathInfo}"); // html doc
routes.IgnoreRoute ("favicon.ico");
routes.IgnoreRoute ("favicon.png");
routes.IgnoreRoute ("robots.txt");
routes.MapRoute (
"Blog",
"Blog/{user}/{title}",
new { controller = "Blogs", action = "Index", user=UrlParameter.Optional, title = UrlParameter.Optional }
);
routes.MapRoute (
"Blogs",
"Blogs/{action}/{user}/{title}",
new { controller = "Blogs", action = "Index", user=UrlParameter.Optional, title = UrlParameter.Optional }
);
routes.MapRoute (
"Account",
"Account/{action}/{user}",
new { controller = "Account", action = "Index", user=UrlParameter.Optional }
);
routes.MapRoute (
"Default",
"{controller}/{action}/{user}/{title}",
new { controller = defaultController,
action = "Index",
user=UrlParameter.Optional,
title = UrlParameter.Optional }
);
}
/// <summary>
/// Starts the Application.
/// </summary>
protected void Application_Start ()
{
AreaRegistration.RegisterAllAreas ();
WebApiConfig.Register (GlobalConfiguration.Configuration);
RegisterRoutes (RouteTable.Routes);
}
/// <summary>
/// Applications the post authorize request.
/// </summary>
protected void Application_PostAuthorizeRequest()
{
if (IsWebApiRequest())
{
HttpContext.Current.SetSessionStateBehavior(SessionStateBehavior.Required);
}
}
private bool IsWebApiRequest()
{
return HttpContext.Current.Request.AppRelativeCurrentExecutionFilePath.StartsWith(WebApiConfig.UrlPrefixRelative);
}
protected void Application_BeginRequest()
{
var ob = typeof(
AspNetRequestScopeStorageProvider).Assembly.GetType(
"System.Web.WebPages.WebPageHttpModule").GetProperty
("AppStartExecuteCompleted",
BindingFlags.NonPublic | BindingFlags.Static);
ob.SetValue(null, true, null);
}
}
}