Update to use IISExpress #U4-75 with Aarons fixes

This commit is contained in:
shannon@ShandemVaio
2012-07-19 22:15:15 +06:00
parent c205197683
commit ce90e114df
3 changed files with 226 additions and 175 deletions

View File

@@ -39,6 +39,7 @@
<OldToolsVersion>4.0</OldToolsVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile />
<UseIISExpress>true</UseIISExpress>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<OutputPath>bin\</OutputPath>
@@ -1789,7 +1790,16 @@ xcopy "$(ProjectDir)"..\..\lib\SQLCE4\x86\*.* "$(TargetDir)x86\" /Y /F /E /D</Po
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<SaveServerSettingsInUserFile>True</SaveServerSettingsInUserFile>
<UseIIS>True</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>61637</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl>http://localhost:61637/</IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>False</UseCustomServer>
<CustomServerUrl>
</CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>

View File

@@ -15,57 +15,61 @@ using System.Collections.Generic;
namespace umbraco.presentation.install
{
/// <summary>
/// Summary description for _default.
/// </summary>
public partial class _default : BasePages.BasePage
{
/// <summary>
/// Summary description for _default.
/// </summary>
public partial class _default : BasePages.BasePage
{
private string _installStep = "";
private string _installStep = "";
public string currentStepClass = "";
protected void Page_Load(object sender, System.EventArgs e)
{
// use buffer, so content isn't sent until it's ready (minimizing the blank screen experience)
//Response.Buffer = true;
rp_steps.DataSource = InstallerSteps().Values;
rp_steps.DataBind();
}
protected void Page_Load(object sender, System.EventArgs e)
{
// use buffer, so content isn't sent until it's ready (minimizing the blank screen experience)
//Response.Buffer = true;
rp_steps.DataSource = InstallerSteps().Values;
rp_steps.DataBind();
}
private void loadContent(InstallerStep currentStep)
{
PlaceHolderStep.Controls.Clear();
PlaceHolderStep.Controls.Add(new System.Web.UI.UserControl().LoadControl(IOHelper.ResolveUrl( currentStep.UserControl ) ));
step.Value = currentStep.Alias;
private void loadContent(InstallerStep currentStep)
{
PlaceHolderStep.Controls.Clear();
PlaceHolderStep.Controls.Add(new System.Web.UI.UserControl().LoadControl(IOHelper.ResolveUrl(currentStep.UserControl)));
step.Value = currentStep.Alias;
currentStepClass = currentStep.Alias;
}
}
int stepCounter = 0;
protected void bindStep(object sender, RepeaterItemEventArgs e) {
int stepCounter = 0;
protected void bindStep(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) {
InstallerStep i = (InstallerStep)e.Item.DataItem;
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
InstallerStep i = (InstallerStep)e.Item.DataItem;
if (!i.HideFromNavigation) {
Literal _class = (Literal)e.Item.FindControl("lt_class");
Literal _name = (Literal)e.Item.FindControl("lt_name");
if (!i.HideFromNavigation)
{
Literal _class = (Literal)e.Item.FindControl("lt_class");
Literal _name = (Literal)e.Item.FindControl("lt_name");
if (i.Alias == currentStepClass)
_class.Text = "active";
if (i.Alias == currentStepClass)
_class.Text = "active";
stepCounter++;
_name.Text = (stepCounter).ToString() + " - " + i.Name;
}
else
e.Item.Visible = false;
}
}
stepCounter++;
_name.Text = (stepCounter).ToString() + " - " + i.Name;
} else
e.Item.Visible = false;
}
}
public void GotoNextStep(string currentStep)
{
InstallerStep _s = InstallerSteps().GotoNextStep(currentStep);
Response.Redirect("?installStep=" + _s.Alias);
InstallerStep _s = InstallerSteps().GotoNextStep(currentStep);
Response.Redirect("?installStep=" + _s.Alias);
}
public void GotoLastStep()
@@ -75,62 +79,70 @@ namespace umbraco.presentation.install
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
InitializeComponent();
base.OnInit(e);
_installStep = helper.Request("installStep");
InstallerStep _s;
//if this is not an upgrade we will log in with the default user.
if (!String.IsNullOrEmpty(GlobalSettings.ConfigurationStatus.Trim())) {
try {
ensureContext();
} catch {
Response.Redirect(SystemDirectories.Umbraco + "/logout.aspx?redir=" + Server.UrlEncode(Request.RawUrl));
}
if (!String.IsNullOrEmpty(GlobalSettings.ConfigurationStatus.Trim()))
{
try
{
ensureContext();
}
catch (InvalidOperationException ex)
{
//set the first step to upgrade.
// if (string.IsNullOrEmpty(_installStep))
// _installStep = "upgrade";
}
}
catch (Exception)
{
Response.Redirect(SystemDirectories.Umbraco + "/logout.aspx?redir=" + Server.UrlEncode(Request.RawUrl));
}
//set the first step to upgrade.
// if (string.IsNullOrEmpty(_installStep))
// _installStep = "upgrade";
}
if (string.IsNullOrEmpty(_installStep))
_s = InstallerSteps()["welcome"];
else
_s = InstallerSteps()[_installStep];
loadContent(_s);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
loadContent(_s);
}
}
#endregion
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
}
#endregion
private static InstallerStepCollection InstallerSteps()
{
InstallerStepCollection ics = new InstallerStepCollection();
ics.Add(new install.steps.Definitions.Welcome());
private static InstallerStepCollection InstallerSteps()
{
InstallerStepCollection ics = new InstallerStepCollection();
ics.Add(new install.steps.Definitions.Welcome());
ics.Add(new install.steps.Definitions.License());
ics.Add(new install.steps.Definitions.FilePermissions());
ics.Add(new install.steps.Definitions.Database());
ics.Add(new install.steps.Definitions.FilePermissions());
ics.Add(new install.steps.Definitions.Database());
ics.Add(new install.steps.Definitions.DefaultUser());
ics.Add( new install.steps.Definitions.Skinning() );
ics.Add(new install.steps.Definitions.Skinning());
ics.Add(new install.steps.Definitions.WebPi());
ics.Add(new install.steps.Definitions.TheEnd());
return ics;
}
return ics;
}
}
}
}

View File

@@ -7,21 +7,23 @@ using umbraco.DataLayer;
using umbraco.IO;
using System.Web.UI;
namespace umbraco.BasePages {
namespace umbraco.BasePages
{
/// <summary>
/// umbraco.BasePages.BasePage is the default page type for the umbraco backend.
/// The basepage keeps track of the current user and the page context. But does not
/// Restrict access to the page itself.
/// The keep the page secure, the umbracoEnsuredPage class should be used instead
/// </summary>
public class BasePage : System.Web.UI.Page {
public class BasePage : System.Web.UI.Page
{
private User _user;
private bool _userisValidated = false;
private ClientTools m_clientTools;
private ClientTools _clientTools;
// ticks per minute 600,000,000
private static long _ticksPrMinute = 600000000;
private static int _umbracoTimeOutInMinutes = GlobalSettings.TimeOutInMinutes;
private const long TicksPrMinute = 600000000;
private static readonly int UmbracoTimeOutInMinutes = GlobalSettings.TimeOutInMinutes;
/// <summary>
/// The path to the umbraco root folder
@@ -42,71 +44,82 @@ namespace umbraco.BasePages {
/// Gets the SQL helper.
/// </summary>
/// <value>The SQL helper.</value>
protected static ISqlHelper SqlHelper {
protected static ISqlHelper SqlHelper
{
get { return umbraco.BusinessLogic.Application.SqlHelper; }
}
/// <summary>
/// Initializes a new instance of the <see cref="BasePage"/> class.
/// </summary>
public BasePage() {
public BasePage()
{
}
/// <summary>
/// Returns the current BasePage for the current request.
/// This assumes that the current page is a BasePage, otherwise, returns null;
/// </summary>
public static BasePage Current
{
get
{
return HttpContext.Current.CurrentHandler as BasePage;
}
}
/// <summary>
/// Returns a refernce of an instance of ClientTools for access to the pages client API
/// </summary>
public ClientTools ClientTools
{
get
{
if (m_clientTools == null)
m_clientTools = new ClientTools(this);
return m_clientTools;
}
}
[Obsolete("Use ClientTools instead")]
public void RefreshPage(int Seconds)
{
ClientTools.RefreshAdmin(Seconds);
/// <summary>
/// Returns the current BasePage for the current request.
/// This assumes that the current page is a BasePage, otherwise, returns null;
/// </summary>
public static BasePage Current
{
get
{
return HttpContext.Current.CurrentHandler as BasePage;
}
}
private void validateUser() {
if ((umbracoUserContextID != "")) {
/// <summary>
/// Returns a refernce of an instance of ClientTools for access to the pages client API
/// </summary>
public ClientTools ClientTools
{
get
{
if (_clientTools == null)
_clientTools = new ClientTools(this);
return _clientTools;
}
}
[Obsolete("Use ClientTools instead")]
public void RefreshPage(int Seconds)
{
ClientTools.RefreshAdmin(Seconds);
}
private void ValidateUser()
{
if ((umbracoUserContextID != ""))
{
uid = GetUserId(umbracoUserContextID);
timeout = GetTimeout(umbracoUserContextID);
if (timeout > DateTime.Now.Ticks) {
if (timeout > DateTime.Now.Ticks)
{
_user = BusinessLogic.User.GetUser(uid);
// Check for console access
if (_user.Disabled || (_user.NoConsole && GlobalSettings.RequestIsInUmbracoApplication(HttpContext.Current) && !GlobalSettings.RequestIsLiveEditRedirector(HttpContext.Current)))
{
throw new ArgumentException("You have no priviledges to the umbraco console. Please contact your administrator");
}
}
else
{
_userisValidated = true;
updateLogin();
UpdateLogin();
}
} else {
}
else
{
throw new ArgumentException("User has timed out!!");
}
} else
throw new ArgumentException("The user has no umbraco contextid - try logging in");
}
else
{
throw new InvalidOperationException("The user has no umbraco contextid - try logging in");
}
}
/// <summary>
@@ -114,24 +127,29 @@ namespace umbraco.BasePages {
/// </summary>
/// <param name="umbracoUserContextID">The umbraco user context ID.</param>
/// <returns></returns>
public static int GetUserId(string umbracoUserContextID) {
try {
if (System.Web.HttpRuntime.Cache["UmbracoUserContext" + umbracoUserContextID] == null) {
public static int GetUserId(string umbracoUserContextID)
{
try
{
if (System.Web.HttpRuntime.Cache["UmbracoUserContext" + umbracoUserContextID] == null)
{
System.Web.HttpRuntime.Cache.Insert(
"UmbracoUserContext" + umbracoUserContextID,
SqlHelper.ExecuteScalar<int>("select userID from umbracoUserLogins where contextID = @contextId",
SqlHelper.CreateParameter("@contextId", new Guid(umbracoUserContextID))
),
SqlHelper.CreateParameter("@contextId", new Guid(umbracoUserContextID))
),
null,
System.Web.Caching.Cache.NoAbsoluteExpiration,
new TimeSpan(0, (int)(_umbracoTimeOutInMinutes / 10), 0));
new TimeSpan(0, (int) (UmbracoTimeOutInMinutes/10), 0));
}
return (int)System.Web.HttpRuntime.Cache["UmbracoUserContext" + umbracoUserContextID];
} catch {
}
catch
{
return -1;
}
}
@@ -143,7 +161,8 @@ namespace umbraco.BasePages {
/// </summary>
/// <param name="umbracoUserContextID">The umbraco user context ID.</param>
/// <returns></returns>
public static bool ValidateUserContextID(string currentUmbracoUserContextID) {
public static bool ValidateUserContextID(string currentUmbracoUserContextID)
{
if ((currentUmbracoUserContextID != ""))
{
int uid = GetUserId(currentUmbracoUserContextID);
@@ -153,26 +172,28 @@ namespace umbraco.BasePages {
{
return true;
}
BusinessLogic.Log.Add(BusinessLogic.LogTypes.Logout, BusinessLogic.User.GetUser(uid), -1, "");
}
return false;
}
private static long GetTimeout(string umbracoUserContextID) {
if (System.Web.HttpRuntime.Cache["UmbracoUserContextTimeout" + umbracoUserContextID] == null) {
private static long GetTimeout(string umbracoUserContextID)
{
if (System.Web.HttpRuntime.Cache["UmbracoUserContextTimeout" + umbracoUserContextID] == null)
{
System.Web.HttpRuntime.Cache.Insert(
"UmbracoUserContextTimeout" + umbracoUserContextID,
GetTimeout(true),
null,
DateTime.Now.AddMinutes(_umbracoTimeOutInMinutes / 10), System.Web.Caching.Cache.NoSlidingExpiration);
DateTime.Now.AddMinutes(UmbracoTimeOutInMinutes / 10), System.Web.Caching.Cache.NoSlidingExpiration);
}
object timeout = HttpRuntime.Cache["UmbracoUserContextTimeout" + umbracoUserContextID];
if(timeout != null)
return (long) timeout;
if (timeout != null)
return (long)timeout;
return 0;
@@ -198,25 +219,27 @@ namespace umbraco.BasePages {
/// Gets or sets the umbraco user context ID.
/// </summary>
/// <value>The umbraco user context ID.</value>
public static string umbracoUserContextID {
public static string umbracoUserContextID
{
get
{
// zb-00004 #29956 : refactor cookies names & handling
if (StateHelper.Cookies.HasCookies && StateHelper.Cookies.UserContext.HasValue)
return StateHelper.Cookies.UserContext.GetValue();
else
return "";
// zb-00004 #29956 : refactor cookies names & handling
if (StateHelper.Cookies.HasCookies && StateHelper.Cookies.UserContext.HasValue)
return StateHelper.Cookies.UserContext.GetValue();
else
return "";
}
set {
// zb-00004 #29956 : refactor cookies names & handling
set
{
// zb-00004 #29956 : refactor cookies names & handling
if (StateHelper.Cookies.HasCookies)
{
// Clearing all old cookies before setting a new one.
if (StateHelper.Cookies.UserContext.HasValue)
StateHelper.Cookies.ClearAll();
{
// Clearing all old cookies before setting a new one.
if (StateHelper.Cookies.UserContext.HasValue)
StateHelper.Cookies.ClearAll();
// Create new cookie.
StateHelper.Cookies.UserContext.SetValue(value, 1);
StateHelper.Cookies.UserContext.SetValue(value, 1);
}
}
}
@@ -227,24 +250,24 @@ namespace umbraco.BasePages {
/// </summary>
public void ClearLogin()
{
deleteLogin();
DeleteLogin();
umbracoUserContextID = "";
}
private void deleteLogin()
private void DeleteLogin()
{
SqlHelper.ExecuteNonQuery(
"DELETE FROM umbracoUserLogins WHERE contextId = @contextId",
SqlHelper.CreateParameter("@contextId", umbracoUserContextID));
}
private void updateLogin()
private void UpdateLogin()
{
// only call update if more than 1/10 of the timeout has passed
if (timeout - (((_ticksPrMinute * _umbracoTimeOutInMinutes) * 0.8)) < DateTime.Now.Ticks)
if (timeout - (((TicksPrMinute * UmbracoTimeOutInMinutes) * 0.8)) < DateTime.Now.Ticks)
SqlHelper.ExecuteNonQuery(
"UPDATE umbracoUserLogins SET timeout = @timeout WHERE contextId = @contextId",
SqlHelper.CreateParameter("@timeout", DateTime.Now.Ticks + (_ticksPrMinute * _umbracoTimeOutInMinutes)),
SqlHelper.CreateParameter("@timeout", DateTime.Now.Ticks + (TicksPrMinute * UmbracoTimeOutInMinutes)),
SqlHelper.CreateParameter("@contextId", umbracoUserContextID));
}
@@ -253,7 +276,7 @@ namespace umbraco.BasePages {
// only call update if more than 1/10 of the timeout has passed
SqlHelper.ExecuteNonQuery(
"UPDATE umbracoUserLogins SET timeout = @timeout WHERE contextId = @contextId",
SqlHelper.CreateParameter("@timeout", DateTime.Now.Ticks + (_ticksPrMinute * _umbracoTimeOutInMinutes)),
SqlHelper.CreateParameter("@timeout", DateTime.Now.Ticks + (TicksPrMinute * UmbracoTimeOutInMinutes)),
SqlHelper.CreateParameter("@contextId", umbracoUserContextID));
}
@@ -261,11 +284,12 @@ namespace umbraco.BasePages {
/// Logs a user in.
/// </summary>
/// <param name="u">The user</param>
public static void doLogin(User u) {
public static void doLogin(User u)
{
Guid retVal = Guid.NewGuid();
SqlHelper.ExecuteNonQuery(
"insert into umbracoUserLogins (contextID, userID, timeout) values (@contextId,'" + u.Id + "','" +
(DateTime.Now.Ticks + (_ticksPrMinute * _umbracoTimeOutInMinutes)).ToString() +
(DateTime.Now.Ticks + (TicksPrMinute * UmbracoTimeOutInMinutes)).ToString() +
"') ",
SqlHelper.CreateParameter("@contextId", retVal));
umbracoUserContextID = retVal.ToString();
@@ -277,34 +301,37 @@ namespace umbraco.BasePages {
/// Gets the user.
/// </summary>
/// <returns></returns>
public User getUser() {
if (!_userisValidated) validateUser();
public User getUser()
{
if (!_userisValidated) ValidateUser();
return _user;
}
/// <summary>
/// Ensures the page context.
/// </summary>
public void ensureContext() {
validateUser();
}
[Obsolete("Use ClientTools instead")]
public void speechBubble(speechBubbleIcon i, string header, string body)
{
ClientTools.ShowSpeechBubble(i, header, body);
public void ensureContext()
{
ValidateUser();
}
//[Obsolete("Use ClientTools instead")]
//public void reloadParentNode()
//{
// ClientTools.ReloadParentNode(true);
//}
[Obsolete("Use ClientTools instead")]
public void speechBubble(speechBubbleIcon i, string header, string body)
{
ClientTools.ShowSpeechBubble(i, header, body);
}
//[Obsolete("Use ClientTools instead")]
//public void reloadParentNode()
//{
// ClientTools.ReloadParentNode(true);
//}
/// <summary>
/// a collection of available speechbubble icons
/// </summary>
public enum speechBubbleIcon {
public enum speechBubbleIcon
{
/// <summary>
/// Save icon
/// </summary>
@@ -331,10 +358,12 @@ namespace umbraco.BasePages {
/// Raises the <see cref="E:System.Web.UI.Control.Load"></see> event.
/// </summary>
/// <param name="e">The <see cref="T:System.EventArgs"></see> object that contains the event data.</param>
protected override void OnLoad(EventArgs e) {
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!Request.IsSecureConnection && GlobalSettings.UseSSL) {
if (!Request.IsSecureConnection && GlobalSettings.UseSSL)
{
string serverName = HttpUtility.UrlEncode(Request.ServerVariables["SERVER_NAME"]);
Response.Redirect(string.Format("https://{0}{1}", serverName, Request.FilePath));
}