public void CanAppendSegment_ToEmptyPath_WithTrailingSlash() { Url u = "http://n2cms.com/"; u = u.AppendSegment("test2"); Assert.That(u.ToString(), Is.EqualTo("http://n2cms.com/test2.aspx")); }
public void WillUse_UrlExtension_WhenAppendingSegment() { Url u = "http://n2cms.com/test.html"; u = u.AppendSegment("test2"); Assert.That(u.ToString(), Is.EqualTo("http://n2cms.com/test/test2.html")); }
public void CanAppendSegment_WithoutUsingDefaultExtension_ToEmptyPath() { Url u = "http://n2cms.com"; u = u.AppendSegment("test2", false); Assert.That(u.ToString(), Is.EqualTo("http://n2cms.com/test2")); }
public void CanAppendSegment_ToPathWithTrailingSlash() { Url u = "http://n2cms.com/wiki/"; u = u.AppendSegment("test"); Assert.That(u.ToString(), Is.EqualTo("http://n2cms.com/wiki/test")); }
public void WillNotUse_DefaultExtension_WhenAppendingSegment_ToPathWithNoExtension() { Url u = "http://n2cms.com/test"; u = u.AppendSegment("test2"); Assert.That(u.ToString(), Is.EqualTo("http://n2cms.com/test/test2")); }
public void CanAppendSegment_UsingDefaultExtension_ToPathWithTrailingSlash() { Url u = "http://n2cms.com/path/"; u = u.AppendSegment("test2", true); Assert.That(u.ToString(), Is.EqualTo("http://n2cms.com/path/test2.aspx")); }
public void CanAppendSegment_ToPathWithoutExtension() { Url u = "http://n2cms.com/wiki"; u = u.AppendSegment("test"); Assert.That(u.ToString(), Is.EqualTo("http://n2cms.com/wiki/test")); }
public void CanAppendSegment_WithoutUsingDefaultExtension() { Url u = "http://n2cms.com/hello"; u = u.AppendSegment("test2", false); Assert.AreEqual("http://n2cms.com/hello/test2", u.ToString()); }
public void CanAppendSegment() { Url u = "http://n2cms.com/test.aspx?key=value"; u = u.AppendSegment("test2"); Assert.That(u.ToString(), Is.EqualTo("http://n2cms.com/test/test2.aspx?key=value")); }
public void CanAppendSegment_UsingDefaultExtension_ToEmptyPath() { Url u = "http://n2cms.com"; u = u.AppendSegment("test2", true); Assert.AreEqual("http://n2cms.com/test2.aspx", u.ToString()); }
public void CanAppendSegment_ToEmptyPath() { Url u = "http://n2cms.com"; u = u.AppendSegment("test2"); Assert.AreEqual("http://n2cms.com/test2.aspx", u.ToString()); }
public void CanAppendSegment() { Url u = "http://n2cms.com/test.aspx?key=value"; u = u.AppendSegment("test2"); Assert.AreEqual("http://n2cms.com/test/test2.aspx?key=value", u.ToString()); }
protected void save_Click(object sender, EventArgs e) { Page.Validate(); cvAuthenticated.IsValid = IsAuthorized(Page.User); if (!Page.IsValid) { return; } Items.Addon addon = CurrentItem as Items.Addon; if (addon == null) { addon = Engine.Resolve <ContentActivator>().CreateInstance <Items.Addon>(CurrentPage); addon.AuthorUserName = Page.User.Identity.Name; } else if (!IsAuthor(Page.User, addon)) { cvAuthenticated.IsValid = false; return; } addon.Title = Encode(txtTitle.Text); addon.Name = Engine.Resolve <HtmlFilter>().CleanUrl(txtTitle.Text); addon.Text = Encode(txtDescription.Text); addon.AddonVersion = Encode(txtVersion.Text); addon.Category = (Items.CodeCategory)AssembleSelected(cblCategory.Items); addon.ContactEmail = Encode(txtEmail.Text); addon.ContactName = Encode(txtName.Text); addon.HomepageUrl = Encode(txtHomepage.Text); addon.LastTestedVersion = Encode(txtN2Version.Text); addon.Requirements = (Items.Requirement)AssembleSelected(cblRequirements.Items); addon.SourceCodeUrl = Encode(txtSource.Text); addon.Summary = Encode(txtSummary.Text); if (fuAddon.PostedFile.ContentLength > 0) { IFileSystem fs = Engine.Resolve <IFileSystem>(); if (!string.IsNullOrEmpty(addon.UploadedFileUrl)) { if (File.Exists(addon.UploadedFileUrl)) { File.Delete(addon.UploadedFileUrl); } } string fileName = Path.GetFileName(fuAddon.PostedFile.FileName); Url folder = Url.Parse(Engine.EditManager.UploadFolders[0]).AppendSegment("Addons"); if (!fs.DirectoryExists(folder)) { fs.CreateDirectory(folder); } addon.UploadedFileUrl = folder.AppendSegment(Path.GetFileNameWithoutExtension(fileName), Path.GetExtension(fileName)); fs.WriteFile(addon.UploadedFileUrl, fuAddon.PostedFile.InputStream); } Engine.Persister.Save(addon); Response.Redirect(addon.Url); }
public void AppendEmptySegment_ToUrlWithExtension() { Url url = "/hello.aspx"; url = url.AppendSegment("/"); url.ToString().ShouldBe("/hello.aspx"); }
protected void btnSearch_Click(object sender, EventArgs e) { var filter = Engine.Resolve <HtmlFilter>(); string text = filter.CleanUrl(txtSearch.Text); Url url = Viewed.Article.WikiRoot.Url; url = url.AppendSegment("search").AppendSegment(text); Response.Redirect(url); }
/// <summary> /// Code to emulate IIS handling of folders / default documents. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks> /// Verify if this code is really needed when running under IIS7 - it could most likely be disabled then... /// </remarks> private void Global_AuthenticateRequest(object sender, EventArgs e) { // Emulate IIS directory redirection and default document handling. string path = Request.Url.AbsolutePath; // If we're referring to a directory but no document, try to find an existing default document. if (path.EndsWith("/")) { // Get an array of possible choices for default documents. string[] defaultDocuments = GetDefaultDocuments(Request.Url); if (defaultDocuments != null) { foreach (string defaultDocument in defaultDocuments) { Url defaultUrl = new Url(Request.Url); defaultUrl = defaultUrl.AppendSegment(defaultDocument); // If this path actually exists... if (HostingEnvironment.VirtualPathProvider.FileExists(defaultUrl.Path)) { // ....rewrite the path to refer to this default document, and serve it up HttpContext.Current.RewritePath(defaultUrl.Path + defaultUrl.Querystring); break; } } } return; } // Request URL does not end with a slash, check if we have a corresponding directory if (HostingEnvironment.VirtualPathProvider.DirectoryExists(path)) { // TODO - check if this may be a problem - redirecting with host name? // if we're referring to an existing directory, add a "/" and redirect path += "/"; // NOTE! Since we are changing the nesting level of the request, we must do a redirect to ensure // that the browser requesting the information is in sync with regards to the base URL. Response.Redirect(path); } }