* Profile.aspx: * ProfileEdition.cs: Fixes the username modification * Book-next.aspx: pollution * NpgsqlMembershipProvider.cs: xmldoc * NpgsqlProfileProvider.cs: use default values from configuration * NpgsqlUserNameProvider.cs: Fixes the username detection * test-domain-TestAPI.config: profile dates must be returned as DateTime * instdbws.sql: The conversion to a valid .Net DateTime requires a credible date time as source value, the null one is not supported. * style.css: Fixes the new notification style * AccountController.cs: Fixes the profile edition. Now using the anti forgery key at login time * Book.aspx: * LocalizedText.resx: * LocalizedText.fr.resx: * CalendarApi.cs: * GoogleController.cs: * LocalizedText.Designer.cs: * LocalizedText.fr.Designer.cs: WIP booking * HomeController.cs: code prettying * Global.asax.cs: Limits the usage of titles in a route to the blog controller * OAuth2.cs: Profile values may be of type DBNull ... * T.cs: All translated strings will be Html encoded, as expected from an html helper * YavscHelpers.cs: A new method to build a javascript string... * App.master: * AppAdmin.master: Notification.body is now a js string literal * NoLogin.master: sync with the true master * Login.aspx: Permits the anti forgery key usage * Estimate.aspx: refactoring * Web.config: Fixes a later commit on the catalog name space * Web.csproj: An ajax helper to notify * ChangePasswordModel.cs: * RegisterClientModel.cs: A regexp for user name * LoginModel.cs: A regexp for user name and password * Profile.cs: A regexp for user name, and profile usage fixes * UserManager.cs: Checks for username availability before trying to modify it * YavscModel.csproj: `ProfileEdition` class addition * ChangeLog: should not be indexed * ChangeLog: useless here * ValidateAjaxAttribute.cs: Fixes usage of HtmlFieldPrefix * BookQuery.cs: Start, end hour and role are required * OtherWebException.cs: useless
133 lines
3.7 KiB
C#
133 lines
3.7 KiB
C#
|
|
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 in a POS,
|
|
string defaultController =
|
|
WebConfigurationManager.AppSettings ["DefaultController"];
|
|
if (defaultController == null)
|
|
defaultController = "Home";
|
|
routes.IgnoreRoute ("{resource}.axd/{*pathInfo}"); // not used
|
|
routes.IgnoreRoute ("Scripts/{*pathInfo}"); // web user side scripts
|
|
routes.IgnoreRoute ("App_Theme/{*pathInfo}"); // sites themes
|
|
routes.IgnoreRoute ("images/{*pathInfo}"); // site images
|
|
routes.IgnoreRoute ("users/{*pathInfo}"); // user's files
|
|
routes.IgnoreRoute ("avatars/{*pathInfo}"); // user's avatar
|
|
routes.IgnoreRoute ("bfiles/{*pathInfo}"); // Blog files
|
|
routes.IgnoreRoute ("xmldoc/{*pathInfo}"); // xml doc
|
|
routes.IgnoreRoute ("htmldoc/{*pathInfo}"); // html doc
|
|
routes.IgnoreRoute ("fonts/{*pathInfo}"); // fonts
|
|
routes.IgnoreRoute ("favicon.ico"); // favorite icon
|
|
routes.IgnoreRoute ("favicon.png"); // favorite icon
|
|
routes.IgnoreRoute ("robots.txt"); // for search engine robots
|
|
routes.MapRoute (
|
|
"Titles",
|
|
"title/{title}",
|
|
new { controller = "Blogs", action = "Index",
|
|
title=UrlParameter.Optional }
|
|
);
|
|
routes.MapRoute (
|
|
"Blogs",
|
|
"blog/{user}",
|
|
new { controller = "Blogs",
|
|
action = "UserPosts",
|
|
user="Paul Schneider" }
|
|
);
|
|
|
|
routes.MapRoute (
|
|
"BlogByTitle",
|
|
"by/{user}/{title}/{id}",
|
|
new { controller = "Blogs",
|
|
action = "UserPosts",
|
|
user="Paul Schneider",
|
|
title=UrlParameter.Optional,
|
|
id=UrlParameter.Optional }
|
|
);
|
|
routes.MapRoute (
|
|
"BlogById",
|
|
"b/{action}/{postid}",
|
|
new { controller = "Blogs", action = "Index",
|
|
postid=UrlParameter.Optional }
|
|
);
|
|
routes.MapRoute (
|
|
"BackCompat",
|
|
"Blogs/{action}/{user}/{title}",
|
|
new { controller = "Blogs", action = "Index", user = UrlParameter.Optional, title = UrlParameter.Optional }
|
|
);
|
|
|
|
routes.MapRoute (
|
|
"Default",
|
|
"{controller}/{action}/{id}",
|
|
new { controller = "Home", action = "Index", id = 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);
|
|
}
|
|
|
|
/// <summary>
|
|
/// begins a request against this application.
|
|
/// </summary>
|
|
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);
|
|
|
|
}
|
|
}
|
|
}
|
|
|