public void TestLoginReturnUrl() { var vertical = CreateVertical(); // Create the member first. var member = CreateMember(EmailAddress, FirstName, LastName, vertical.Id, true, ExternalId); // Try with no cookie to a general page, should be redirected with a return url. var url = vertical.GetVerticalHostUrl("").AsNonReadOnly(); url = new ApplicationUrl(url, "members/friends/Invitations.aspx") { Scheme = Uri.UriSchemeHttps }; Get(url); var externalLoginUrl = new ReadOnlyUrl(vertical.ExternalLoginUrl, new ReadOnlyQueryString("returnUrl", url.AbsoluteUri)); AssertUrl(externalLoginUrl); // Set the cookie and try again, should be logged in. CreateExternalCookies(url, ExternalId, EmailAddress, FirstName + " " + LastName, vertical.ExternalCookieDomain); Get(url); AssertPage <Invitations>(); AssertPageContains("Logged in as <div class=\"user-name\">" + FirstName + " " + LastName + "</div>"); // Check. AssertMember(EmailAddress, FirstName, LastName, vertical.Id, _membersQuery.GetMember(EmailAddress)); Assert.IsNull(_loginCredentialsQuery.GetCredentials(member.Id)); AssertCredentials(vertical.Id, ExternalId, _externalCredentialsQuery.GetCredentials(member.Id, vertical.Id)); }
private Url GetResultUrl() { Url url = new ApplicationUrl(Request.Url.AbsolutePath); url.QueryString.Add(SearchHelper.MemberIdParam, OwnerOfFriends.Id.ToString()); return(url); }
private Url GetResultUrl() { Url url = new ApplicationUrl(Request.Url.AbsolutePath); url.QueryString.Add(QryStrSwitchedMode, GetCurrentMode().ToString()); return(url); }
/// <summary> /// If removing the specified item from the list (specified using a relative index, relative to the /// current page) would result in having to display a different page of results, returns the url of that /// page, otherwise null. Call this method whenever an item is removed from the list. If it returns null /// then refresh the results on the same page, otherwise redirect to the returned URL. /// </summary> public Url GetRedirectUrlAfterRemovingItem(int relativeIndex) { if (string.IsNullOrEmpty(StartIndexParam)) { throw new InvalidOperationException("StartIndexParam must be set before calling" + "GetRedirectUrlAfterRemovingItem()."); } int currentPageIndex = GetCurrentPageNumber(); // We only need to redirect if this was the first result on the page, the last result over and there // are still results left. if (relativeIndex != 0) { return(null); } int absoluteIndex = GetAbsoluteResultIndex(relativeIndex, currentPageIndex); if (absoluteIndex == 0 || absoluteIndex != _totalResults - 1) { return(null); } Url url = new ApplicationUrl(Request.Url.AbsoluteUri); url.QueryString[StartIndexParam] = GetAbsoluteResultIndex(0, currentPageIndex - 1).ToString(); return(url); }
private void Initialize(ApplicationUrl siteMapUrl, NameValueCollection attributes) { string siteMapFile = "~" + siteMapUrl.AppRelativePath; attributes.Add("siteMapFile", siteMapFile); Initialize(siteMapFile, attributes); }
private static ReadOnlyUrl GetReturnUrl(NameValueCollection queryString) { if (queryString == null) { throw new ArgumentNullException("queryString"); } var returnUrlParameter = queryString[Apps.Asp.Constants.ReturnUrlParameter]; if (string.IsNullOrEmpty(returnUrlParameter)) { return(null); } Url returnUrl; try { returnUrl = new ApplicationUrl(returnUrlParameter); } catch (UriFormatException) { returnUrl = new ApplicationUrl(HttpUtility.UrlDecode(returnUrlParameter)); } return(!IsAllowedRedirects(returnUrl) ? null : returnUrl); }
public void TestJobTitleWithExtraCharacters() { var employer = CreateEmployer(); var industry = _industriesQuery.GetIndustries()[0]; var location = GetLocation("Dandenong VIC"); // Create a job with a title with a '\n' plus extra characters. const string jobTitle = "CREDIT SUPERVISOR/ASSISTANT CREDIT MANAGER - sth east - great\n $$ - industry guru"; var jobAd = CreateJobAd(employer, jobTitle, location, industry); // Browse to a page that has a link to the job. var url = new ApplicationUrl("~/jobs/victoria/" + industry.UrlName + "-jobs/"); Get(url); // Follow the link. var jobUrl = Browser.CurrentHtml.DocumentNode.SelectSingleNode("//div[@class='column title']/a").Attributes["href"].Value; Assert.IsTrue(!jobUrl.Contains("%")); Get(new ApplicationUrl(jobUrl)); AssertUrl(new ReadOnlyApplicationUrl(true, "~/jobs/" + location.ToString().Replace(" ", "-").ToLower() + "/" + industry.UrlName + "/" + jobAd.Title.Replace(" ", "-").Replace("/", "").Replace("$", "").Replace("\n", "").Replace("--", "-").Replace("--", "-").Replace("--", "-").Replace("--", "-").ToLower() + "/" + jobAd.Id)); }
public void TestCannotUpdateSettings() { var vertical = CreateVertical(); var url = vertical.GetVerticalHostUrl(""); // Login. CreateMember(EmailAddress, FirstName, LastName, vertical.Id, true, ExternalId); CreateExternalCookies(url, ExternalId, EmailAddress, FirstName + " " + LastName, vertical.ExternalCookieDomain); Get(url); url = vertical.GetVerticalHostUrl("").AsNonReadOnly(); url = new ApplicationUrl(url, "members/settings") { Scheme = Uri.UriSchemeHttps }; Get(url); // Check. Assert.IsTrue(_settingsEmailAddressTextBox.IsVisible); Assert.IsTrue(_settingsEmailAddressTextBox.IsReadOnly); Assert.IsTrue(_settingsFirstNameTextBox.IsVisible); Assert.IsTrue(_settingsFirstNameTextBox.IsReadOnly); Assert.IsTrue(_settingsLastNameTextBox.IsVisible); Assert.IsTrue(_settingsLastNameTextBox.IsReadOnly); Assert.IsFalse(_settingsSaveButton.IsVisible); AssertPageDoesNotContain("Change my password"); AssertPageDoesNotContain("Deactivate my account"); }
private static MachineKeySection GetMachineKey() { string applicationPath = new ApplicationUrl("~/").Path; System.Configuration.Configuration config = WebConfigurationManager.OpenWebConfiguration(applicationPath); return((MachineKeySection)config.GetSection("system.web/machineKey")); }
public void Equals_different_references_can_still_be_equal() { var applicationUrl1 = new ApplicationUrl("http://www.test.com"); var applicationUrl2 = new ApplicationUrl("http://www.test.com"); applicationUrl1.Equals(applicationUrl2).ShouldBeTrue(); }
private void InitPagingBar(int resultsCount, string query) { Url url = new ApplicationUrl(Request.Url.AbsolutePath); url.QueryString.Add(NameQueryParameter, query); ucPagingBar.InitPagesList(url, resultsCount, false); }
private static string UpdateLinks(string contents, ICollection <string> references) { string url = new ApplicationUrl("~/").AbsoluteUri + "/Email/"; var sb = new StringBuilder(); int pos = contents.IndexOf(url); while (pos != -1) { sb.Append(contents.Substring(0, pos)); contents = contents.Substring(pos + url.Length); // Look for the file name. pos = contents.IndexOf("\""); string file = contents.Substring(0, pos); if (!references.Contains(url + file)) { references.Add(url + file); } sb.Append(file); contents = contents.Substring(pos); pos = contents.IndexOf(url); } sb.Append(contents); return(sb.ToString()); }
private static ReadOnlyUrl GetUrl(TinyUrlMapping mapping) { if (string.IsNullOrEmpty(mapping.Definition)) { return(mapping.LongUrl); } // Add in tracking parameters. var url = mapping.LongUrl.AsNonReadOnly(); // If it is a login or activation page then change the returnUrl parameter. if (url.Path.EndsWith("/login") || url.Path.EndsWith("/activation")) { var queryStringReturnUrl = url.QueryString["returnUrl"]; if (queryStringReturnUrl != null) { var returnUrl = new ApplicationUrl(queryStringReturnUrl); AddTracking(mapping.Definition, returnUrl); url.QueryString["returnUrl"] = returnUrl.PathAndQuery; return(url); } } AddTracking(mapping.Definition, url); return(url); }
private void TestOrderLoggedIn(bool verified) { var employer = CreateEmployer(1, verified); var creditCard = new CreditCard { CardHolderName = CardHolderName, CardNumber = CreditCardNumber, CardType = CreditCardType.MasterCard, Cvv = Cvv, ExpiryDate = new ExpiryDate(DateTime.Now.AddYears(1)) }; var order = _ordersCommand.PrepareOrder(new[] { _productsQuery.GetProducts()[0].Id }, null, null, creditCard.CardType); _ordersCommand.PurchaseOrder(employer.Id, order, CreatePurchaser(employer), creditCard); // Try to access the page. var url = _orderUrl.AsNonReadOnly(); url.Path = url.Path + "/"; url = new ApplicationUrl(url, order.Id.ToString()); TestLoggedIn(employer, url); }
protected string GetTinyUrl(TemplateEmail email, string mimeType, int instance, bool secure, string applicationPath, QueryString queryString) { var url = new ApplicationUrl(applicationPath, queryString); var affiliateId = _affiliateEmailsQuery.GetAffiliateId(email); var mappings = _tinyUrlQuery.GetMappings(WebSite.LinkMe, affiliateId, secure, url.IsAbsolute ? url.AbsoluteUri : "~" + url.AppRelativePathAndQuery, email.Id, mimeType, instance); return(mappings.Count == 0 ? null : _webSiteQuery.GetUrl(WebSite.LinkMe, affiliateId, false, "~/url/" + mappings[0].TinyId.ToString("n")).AbsoluteUri); }
protected ReadOnlyUrl GetManageCandidatesUrl(Guid jobAdId, ApplicantStatus?status) { var url = new ApplicationUrl(_baseManageCandidatesUrl, jobAdId.ToString()); if (status != null) { url.QueryString["status"] = status.ToString(); } return(url); }
private static string GetApplicantsText(Guid?jobAdId, int applicants, ApplicantStatus status) { if (applicants == 0) { return(status.ToString()); } var url = new ApplicationUrl("~/employers/candidates/manage/" + jobAdId, new ReadOnlyQueryString("status", status.ToString())); return("<a href=\"" + url.PathAndQuery + "\">" + status + "</a>"); }
private static ReadOnlyUrl GetPartialFaqUrl(Guid faqId, string keywords) { var url = new ApplicationUrl("~/faqs/faq/partial", new ReadOnlyQueryString("id", faqId.ToString())); if (!string.IsNullOrEmpty(keywords)) { url.QueryString["keywords"] = keywords; } return(url); }
private static ReadOnlyUrl GetFaqUrl(Resource faq, string keywords, IEnumerable <Category> categories) { var subcategory = (from s in categories.SelectMany(c => c.Subcategories) where s.Id == faq.SubcategoryId select s).Single(); var url = new ApplicationUrl("~/faqs/" + subcategory.Name.EncodeUrlSegment() + "/" + faq.Title.EncodeUrlSegment() + "/" + faq.Id); if (!string.IsNullOrEmpty(keywords)) { url.QueryString["keywords"] = keywords; } return(url); }
private void TestCanonicalLink(string path) { var url = new ApplicationUrl(path); Get(url); AssertCanonicalLink(url); url.QueryString["aaa"] = "bbb"; url.QueryString["ccc"] = "ddd"; Get(url); AssertCanonicalLink(url); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); txtUserId.Attributes["onKeyPress"] = string.Format("return userIdKeyPress(event, '{0}');", txtPassword.ClientID); if (ApplicationContext.Instance.GetBoolProperty(ApplicationContext.SSL_REDIRECT_LOGINS)) { Url url; if (string.IsNullOrEmpty(frmLogin.Action)) { url = GetClientUrl().AsNonReadOnly(); url.Scheme = Url.SecureScheme; } else { url = new ApplicationUrl(true, frmLogin.Action); } frmLogin.Action = url.ToString(); } if (frmLogin.IsPostBack) { UserId = UserId; // This looks like such a hack - and, yes, it is. ProcessLogin(false); } else { if (string.IsNullOrEmpty(UserId)) { UserId = GetQueryStringUserId(); if (UserId.Length > 0 && Request.QueryString[UserIdKnownParameter] == bool.TrueString) { lblLoginMsg.Text = "Email recognised, enter password and log in."; phLoginMsg.Visible = true; } if (PrepopulateFields()) // remember me sets the user & password textboxes { ProcessLogin(true); } } if (GrabFocusOnLoad) { SetFocusOnControl(string.IsNullOrEmpty(UserId) ? txtUserId : txtPassword); } } }
protected override void DoInitialize(string name, NameValueCollection attributes) { base.DoInitialize(name, attributes); // Look for the siteMapFile. string siteMapFile = attributes["siteMapFile"]; if (!string.IsNullOrEmpty(siteMapFile)) { _siteMapUrl = new ApplicationUrl(siteMapFile); } }
private XmlDocument GetDocument() { var document = new XmlDocument(); if (_siteMapUrl == null) { _siteMapUrl = new ApplicationUrl("~/Web.sitemap"); } string path = HttpContext.Current.Request.MapPath(_siteMapUrl.Path); document.Load(path); return(document); }
private static void AssertLinkPath(ReadOnlyUrl url) { var path = url.Path; var applicationPath = new ApplicationUrl("~/").Path; Assert.IsTrue(path.StartsWith(applicationPath)); var applicationRelativePath = path.Substring(applicationPath.Length - 1); if (!TinyUrlRegex.Match(applicationRelativePath).Success) { Assert.Fail("Link '" + applicationRelativePath + "' does not correspond to a tiny url, '~/url/<guid>'."); } }
private static ReadOnlyUrl GetPartialSearchUrl(Guid?categoryId, string keywords) { var url = new ApplicationUrl("~/faqs/search/partial"); if (categoryId != null) { url.QueryString["categoryId"] = categoryId.Value.ToString(); } if (!string.IsNullOrEmpty(keywords)) { url.QueryString["keywords"] = keywords; } return(url); }
public void ConfigureBase(IApplicationBuilder app, IHostingEnvironment env, string swaggerUrl, string swaggerDescription) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Use(async(context, next) => { var requestUrl = context.Request.Path.ToString(); if (IsApiUrl(requestUrl)) { var appurl = new ApplicationUrl(requestUrl); context.Items[ServiceBaseConstant.ApplicationContext] = ManagerBase.BuildAppContext(appurl); context.Items[ServiceBaseConstant.ApplicationRedirectionUrl] = appurl; } await next.Invoke(); }); app.UseMvc(); app.UseSwagger(); app.UseCors(builder => builder.WithOrigins("*") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); app.UseSwaggerUI(c => { c.SwaggerEndpoint(swaggerUrl, swaggerDescription); c.RoutePrefix = ""; }); RegisterServices(app); var configurationSettings = new ConfigurationSettings() { ConfigDbConnectionString = Configuration.GetSection("ConfigurationSettings")["ConfigDBConnectionString"], MasterApiBaseUrl = Configuration.GetSection("ConfigurationSettings")["MasterApiBaseUrl"], MasterApi = Configuration.GetSection("ConfigurationSettings")["MasterApi"], MasterPort = Configuration.GetSection("ConfigurationSettings")["MasterPort"], MasterVersion = Configuration.GetSection("ConfigurationSettings")["MasterVersion"], //SmsApplicantTemplate = Configuration.GetSection("ConfigurationSettings")["SmsApplicantTemplate"], //SmsApplicantResubmissionTemplate = Configuration.GetSection("ConfigurationSettings")["SmsApplicantResubmissionTemplate"] }; Container.RegisterSingleton <ConfigurationSettings>(() => configurationSettings); }
private void AssertBrand(VerticalTestData data, bool expectBrand) { // Look for the header if appropriate. var imageUrl = new ApplicationUrl(data.CandidateImageUrl); if (expectBrand) { AssertPageContains(imageUrl.FileName); } else { AssertPageDoesNotContain(imageUrl.FileName); } }
public static Url GetFullExternalApplyUrl(InternalApplication jobApplication, JobAdView jobAd) { if (jobApplication == null) { throw new ArgumentNullException("jobApplication"); } var jobAppUrl = JobAdsRoutes.Application.GenerateUrl(new { applicationId = jobApplication.Id }); var jobExternalApplyUrl = new ApplicationUrl(jobAd.Integration.ExternalApplyUrl); jobExternalApplyUrl.QueryString.Add(ExternalApplyUrlLinkmeApplicationIDParam, jobApplication.Id.ToString("n")); jobExternalApplyUrl.QueryString.Add(ExternalApplyUrlLinkmeApplicationUriParam, jobAppUrl.AbsoluteUri); return(jobExternalApplyUrl); }
public static ReadOnlyUrl GetLoginRedirectUrl(string userName) { var url = new ApplicationUrl(FormsAuthentication.GetRedirectUrl(userName, false)); // Remove '/default.aspx' if it is there. if (!url.Path.EndsWith("/default.aspx", StringComparison.InvariantCultureIgnoreCase)) { return(url); } // Only remove the default.aspx to cater for the root in a dev environment. url.Path = url.Path.Substring(0, url.Path.Length - "default.aspx".Length); return(url); }
private SiteMapNode GetSiteMapNodeFromFile(string siteMapFile) { // Create a new provider. var provider = new NavigationSiteMapProvider(); // Initialise it with the relative path to its file. var providerSiteMapUrl = new ApplicationUrl(_siteMapUrl, siteMapFile); provider.Initialize(providerSiteMapUrl, GetChildAttributes()); provider.ParentProvider = this; AddChildProvider(provider); return(provider.RootNode); }