protected void btnNext_Click(object sender, EventArgs e) { if (PageNumberQS > 0 && !LandingPageQS) { SyncPostPage(); } //Redirect bool autoScroll = chkAutoScroll.Checked; string url = UrlCreator.BuildUrl(UserIDQS, PageNumberQS + 1, false, autoScroll); if (PageNumberQS == 0) //go to landing page { url = UrlCreator.BuildUrl(UserIDQS, PageNumberQS + 1, true, autoScroll); } if (PageNumberQS == 1 && LandingPageQS) { url = UrlCreator.BuildUrl(UserIDQS, PageNumberQS, false, autoScroll); } if (PageNumberQS == 25) //TODO: Hardcoded pagesize. { url = UrlCreator.BuildUrl(UserIDQS, PageNumberQS + 1, true, autoScroll); } if (PageNumberQS == 26 && LandingPageQS) //TODO: hardcoded pagesize. { url = UrlCreator.BuildUrl(UserIDQS, PageNumberQS, false, autoScroll); } Response.Redirect(url); }
public virtual void Go(string projectionName) { using (LogGroup logGroup = LogGroup.Start("Navigating.", NLog.LogLevel.Debug)) { string link = new UrlCreator().CreateUrl(projectionName); LogWriter.Debug("Link: " + link); Redirect(link); } }
public void Test_ResultAlreadyExists_True() { string resultText = "Test message"; string applicationPath = "/Test"; string originalUrl = "http://localhost/Test/?Result=" + HttpUtility.UrlEncode(resultText); UrlCreator creator = new UrlCreator(applicationPath, originalUrl); bool alreadyExists = creator.ResultAlreadyExists(resultText); Assert.IsTrue(alreadyExists, "Returned false when it should have returned true."); }
public async Task <IActionResult> Get() { var products = ProductProducer.Products .Select(product => CreateResourceDataOfProduct(product)); var response = new ResourceList <object>(products) .AddLink(UrlCreator .From <ProductController, object>("add", ctrl => ctrl.Post(null)) .WithParams <ProductModel>()); return(await Task.Run(() => Ok(response))); }
private static bool CheckUrl(string Url) { try { WebRequestUtils.SetUpSecurityProtocols(); var request = WebRequest.Create(Url) as HttpWebRequest; using (var client = new MyWebClient()) { client.DownloadString(Url); if (request == null) { return(false); } if (!AppSettings.Site.URLCheckerAllowRedirect && !UrlCreator.ExtractDomainUrl(Url).ToLower().Contains(UrlCreator.ExtractDomainUrl(client.ResponseUri.Host.ToLower()))) { throw new MsgException(U4200.URLCHECKBAD + ": Attempted Redirection"); } //var sourcePage = WebUtility.HtmlDecode(client.DownloadString(Url)).Trim(); //sourcePage = sourcePage.Replace(" ", string.Empty); //if (sourcePage.Contains("top.location!=self.location")) // throw new MsgException(Resources.U4200.URLCHECKBAD); //Some pages send wrong formatted x-frame-options in headers like 'deny' or 'DENY,DENY' so have to use ToLower() and Contains var xFrameHeader = client.ResponseHeaders["X-Frame-Options"] != null ? client.ResponseHeaders["X-Frame-Options"].ToLower() : null; if (xFrameHeader != null && (xFrameHeader.Contains("deny") || xFrameHeader.Contains("sameorigin"))) { throw new MsgException(U6011.WEBSITEDONTALLOWIFRAME); } } return(true); } catch (UriFormatException ex) { //Invalid Url throw new MsgException(Resources.U4200.URLCHECKBAD + ". " + ex.Message); } catch (WebException ex) { //Unable to access url throw new MsgException(Resources.U4200.URLCHECKBAD + ". " + ex.Message); } }
public void Test_CreateXsltUrl() { string applicationPath = "/Test"; string currentUrl = "http://localhost/Test"; UrlCreator creator = new UrlCreator(applicationPath, currentUrl); string action = "TestAction"; string type = "TestType"; string url = creator.CreateXsltUrl(action, type); string expected = "/Test/" + action + "-" + type + ".xslt.aspx"; Assert.AreEqual(expected, url, "The returned URL doesn't match what's expected."); }
private ResourceData <Product> CreateResourceDataOfProduct(Product product) { var data = new ResourceData <Product>(product); data.Links.AddRange(new List <Link> { UrlCreator .From <ProductController, object>("self", ctrl => ctrl.Get(product.Id)), UrlCreator .From <ProductController, object>("edit", ctrl => ctrl.Put(product.Id, null)) .WithParams <ProductModel>(), UrlCreator .From <ProductController, object>("delete", ctrl => ctrl.Delete(product.Id)), }); return(data); }
public void Test_CreateStandardUrl() { string applicationPath = "/Test"; string originalUrl = "http://localhost/Test"; string action = "MockAction"; string typeName = "MockType"; UrlCreator creator = new UrlCreator(applicationPath, originalUrl); string url = creator.CreateStandardUrl(action, typeName); string expectedUrl = "/Test/Projector.aspx?a=" + creator.PrepareForUrl(action) + "&t=" + creator.PrepareForUrl(typeName) + "&f=Html"; Assert.AreEqual(expectedUrl, url, "The URL doesn't match what's expected."); }
public void Test_AddResult() { string applicationPath = "/Test"; string currentUrl = "http://localhost/Test"; UrlCreator creator = new UrlCreator(applicationPath, currentUrl); string original = "http://localhost/Test/Path/"; string resultText = "Test message"; bool resultIsError = false; string result = creator.AddResult(original, resultText, resultIsError); string expected = "http://localhost/Test/Path/?Result=" + creator.PrepareForUrl(resultText) + "&ResultIsError=" + resultIsError.ToString(); Assert.AreEqual(expected, result, "The resulting URL doesn't match what's expected."); }
public void Test_CreateExternalXmlUrl() { string applicationPath = "/Test"; string originalUrl = "http://localhost/Test"; string action = "Create"; string typeName = "User"; UrlCreator creator = new UrlCreator(applicationPath, originalUrl); creator.Converter = new MockUrlConverter(); creator.EnableFriendlyUrls = true; string url = creator.CreateExternalXmlUrl(action, typeName); string expectedUrl = originalUrl + "/" + action + "-" + typeName + ".xml.aspx"; Assert.AreEqual(expectedUrl, url, "The URL doesn't match what's expected."); }
public void Test_CreateFriendlyUrl_MatchProperty() { string applicationPath = "/Test"; string originalUrl = "http://localhost/Test"; string action = "Create"; string typeName = "User"; UrlCreator creator = new UrlCreator(applicationPath, originalUrl); string propertyName = "ID"; string dataKey = Guid.NewGuid().ToString(); string url = creator.CreateFriendlyUrl(action, typeName, propertyName, dataKey); string expectedUrl = "/Test/" + creator.PrepareForUrl(action) + "-" + creator.PrepareForUrl(typeName) + "/" + creator.PrepareForUrl(propertyName) + "--" + creator.PrepareForUrl(dataKey) + ".aspx"; Assert.AreEqual(expectedUrl, url, "The URL doesn't match what's expected."); }
public void Test_CreateXmlUrl() { string applicationPath = "/Test"; string originalUrl = "http://localhost/Test"; string action = "Create"; string typeName = "User"; UrlCreator creator = new UrlCreator(applicationPath, originalUrl); creator.EnableFriendlyUrls = true; string url = creator.CreateXmlUrl(action, typeName); string expectedUrl = "/Test/" + action + "-" + typeName + ".xml.aspx"; Assert.AreEqual(expectedUrl, url, "The URL doesn't match what's expected."); }
public void Test_CreateStandardUrl_MatchProperty() { InitializeMockProjections(); string applicationPath = "/Test"; string originalUrl = "http://localhost/Test"; string action = "Create"; string typeName = "User"; UrlCreator creator = new UrlCreator(applicationPath, originalUrl); string propertyName = "ID"; string dataKey = Guid.NewGuid().ToString(); string url = creator.CreateStandardUrl(action, typeName, propertyName, dataKey); string expectedUrl = "/Test/Projector.aspx?a=" + creator.PrepareForUrl(action) + "&t=" + creator.PrepareForUrl(typeName) + "&f=Html&" + typeName + "-" + propertyName + "=" + creator.PrepareForUrl(dataKey); Assert.AreEqual(expectedUrl, url, "The URL doesn't match what's expected."); }
protected void btnPrev_Click(object sender, EventArgs e) { //TODO: Son page'den geri dönmek isterse son sayfada update ederek dönme. if (PageNumberQS > 0 && !LandingPageQS) { SyncPostPage(); } //Redirect bool autoScroll = chkAutoScroll.Checked; var url = UrlCreator.BuildUrl(UserIDQS, PageNumberQS - 1, false, autoScroll); if (PageNumberQS == 1 || PageNumberQS == 26) { if (!LandingPageQS) { url = UrlCreator.BuildUrl(UserIDQS, PageNumberQS, true, autoScroll); } } Response.Redirect(url); }
public string AddQueryStrings(string path, Dictionary <string, string> queryStrings) { string output = string.Empty; using (LogGroup logGroup = LogGroup.StartDebug("Adding query strings to the path: " + path)) { output = path; UrlCreator urlCreator = new UrlCreator(ApplicationPath, path); foreach (string key in queryStrings.Keys) { string separator = "?"; if (path.IndexOf("?") > -1) { separator = "&"; } LogWriter.Debug("Separator: " + separator); if (output.IndexOf("?" + key + "=") == -1 && output.IndexOf("&" + key + "=") == -1) { LogWriter.Debug("Adding query string \"" + key + "=" + queryStrings[key] + "\""); output = output + separator + urlCreator.PrepareForQueryString(key) + "=" + urlCreator.PrepareForQueryString(queryStrings[key]); LogWriter.Debug("New path: " + output); } else { LogWriter.Debug("Query string key '" + key + "' found in path. Skipping append."); } } LogWriter.Debug("Output: " + output); } return(output); }
public void Test_CreateFriendlyUrl_IEntityParameter_UniqueEntity() { string applicationPath = "/Test"; string originalUrl = "http://localhost/Test"; string action = "View"; TestArticle article = new TestArticle(); article.ID = Guid.NewGuid(); article.Title = "Test article"; UrlCreator creator = new UrlCreator(applicationPath, originalUrl); creator.EnableFriendlyUrls = true; string url = creator.CreateFriendlyUrl(action, article); string expectedUrl = "/Test/" + action + "-" + article.ShortTypeName + "/" + article.ID.ToString() + "/" + creator.PrepareForUrl(article.Title) + ".aspx"; Assert.AreEqual(expectedUrl, url, "The URL doesn't match what's expected."); }
public string GetLink(string action, string type) { return(UrlCreator.CreateUrl(action, type)); }
public static void Initialize(RouteSettings settings) { resolver = new ControllerResolver(); urlCreator = new UrlCreator(settings.RootUrl); }
public string GetStandardLink(string action, string type) { return(UrlCreator.CreateStandardUrl(action, type)); }
public string GetLink() { return(UrlCreator.CreateUrl()); }
public string GetLink(string projectionName) { return(UrlCreator.CreateUrl(projectionName)); }
public string AddQueryStrings(string path, Dictionary<string, string> queryStrings) { string output = string.Empty; using (LogGroup logGroup = LogGroup.StartDebug("Adding query strings to the path: " + path)) { output = path; UrlCreator urlCreator = new UrlCreator(ApplicationPath, path); foreach (string key in queryStrings.Keys) { string separator = "?"; if (path.IndexOf("?") > -1) separator = "&"; LogWriter.Debug("Separator: " + separator); if (output.IndexOf("?" + key + "=") == -1 && output.IndexOf("&" + key + "=") == -1) { LogWriter.Debug("Adding query string \"" + key + "=" + queryStrings[key] + "\""); output = output + separator + urlCreator.PrepareForQueryString(key) + "=" + urlCreator.PrepareForQueryString(queryStrings[key]); LogWriter.Debug("New path: " + output); } else LogWriter.Debug("Query string key '" + key + "' found in path. Skipping append."); } LogWriter.Debug("Output: " + output); } return output; }
public string GetLink(string action, IEntity entity) { return(UrlCreator.CreateUrl(action, entity)); }
protected void CreateAdButton_Click(object sender, EventArgs e) { SPanel.Visible = false; EPanel.Visible = false; try { if (URL.Enabled) { throw new MsgException(U4200.CHECKURL); } NewAdPackAdvert.Title = InputChecker.HtmlEncode(Title.Text, Title.MaxLength, L1.TITLE); NewAdPackAdvert.Description = InputChecker.HtmlEncode(Description.Text, Description.MaxLength, L1.DESCRIPTION); NewAdPackAdvert.TargetUrl = URL.Text; Member admin = new Member(AppSettings.RevShare.AdminUsername); NewAdPackAdvert.CreatorUserId = User.Id; //No need to approve admin's adverts if (NewAdPackAdvert.CreatorUserId == admin.Id) { NewAdPackAdvert.Status = AdvertStatus.Active; } else { NewAdPackAdvert.Status = AdvertStatusExtensions.GetStartingStatus(); } NewAdPackAdvert.AddedAsType = PurchaseOption.Features.SurfAd; UrlVerifier.Check(UrlCreator.ParseUrl(URL.Text)); if (AppSettings.RevShare.AdPack.IsStartPageEnabled && PurchaseStartPageCheckBox.Checked) { if (AdPackManager.GetNumberOfStartPagesPurchasedForDay(StartPageDateCalendar.SelectedDate) > 0) { throw new MsgException("You can't buy a Start Page for a selected date"); } User = Member.Current; Money startPagePrice = AppSettings.RevShare.AdPack.StartPagePrice; if (startPagePrice > User.PurchaseBalance) { throw new MsgException(L1.NOTENOUGHFUNDS); } NewAdPackAdvert.StartPageDate = StartPageDateCalendar.SelectedDate; User.SubtractFromPurchaseBalance(startPagePrice, "Start Page"); User.SaveBalances(); //Add to profit sources PoolDistributionManager.AddProfit(ProfitSource.StartPage, startPagePrice); } NewAdPackAdvert.Save(); //Clear all ClearAll(); BindDataToCampaignsDDL(); //Display info SPanel.Visible = true; if (User.Name == AppSettings.RevShare.AdminUsername) { SText.Text = U3501.ADCREATED; } else { SText.Text = U4200.ADAWAITSAPPROVAL; } AdPacksAdGridView.DataBind(); } catch (MsgException ex) { EPanel.Visible = true; EText.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex); throw ex; } }
public string GetLink(string action, string type, string propertyName, string dataKey) { return(UrlCreator.CreateUrl(action, type, propertyName, dataKey)); }