public override void OnActionExecuting(ActionExecutingContext filterContext) { var helper = new UrlHelper(filterContext.RequestContext); var redirectUrl=helper.AbsoluteAction("Logon", "Account"); var wargamingApi = IoC.Resolve<IWargamingApi>(); filterContext.Controller.ViewBag.OAuthUrl=wargamingApi.GetLoginUrl(redirectUrl); }
public static MvcHtmlString TrackbackRdf(this HtmlHelper html, PostViewModel post) { if (post.AreCommentsClosed || post.Post.IsCommentAllowed == false) { return MvcHtmlString.Create(string.Empty); } var urlHelper = new UrlHelper(html.ViewContext.RequestContext); var postUrl = urlHelper.AbsoluteAction("Details", "PostDetails", post.Post.ToRouteData()); var trackbackUrl = urlHelper.AbsoluteAction("Trackback", "Services", new { id = post.Post.Id }); return MvcHtmlString.Create(GetTrackbackRdf(postUrl, post.Post.Title, trackbackUrl)); }
private string CreateProtectedUrl(string action, CommentPart part) { var workContext = _workContextAccessor.GetContext(); if (workContext.HttpContext != null) { var url = new UrlHelper(workContext.HttpContext.Request.RequestContext); return url.AbsoluteAction(action, "Comment", new {area = "Orchard.Comments", nonce = _commentService.CreateNonce(part, TimeSpan.FromDays(7))}); } return null; }
public override void ExecuteResult(ControllerContext context) { var url = new UrlHelper(HttpContext.Current.Request.RequestContext); var factory = new Elmah.ErrorLogPageFactory(); if (!string.IsNullOrEmpty(_resouceType)) { var pathInfo = "." + _resouceType; HttpContext.Current.RewritePath(url.AbsoluteAction("Index", "Elmah"), pathInfo, HttpContext.Current.Request.QueryString.ToString()); } var handler = factory.GetHandler(HttpContext.Current, null, null, null); handler.ProcessRequest(HttpContext.Current); }
public MvcHtmlString GetPreviewUrl(UrlHelper helper) { var root = HttpContext.Current.Request.ApplicationPath ?? "/"; if (!root.EndsWith("/")) { root += "/"; } var path = string.Format("{0}{1}/{2}", root, SelectedMeme, string.Join("/", Lines)); var strippedPath = _previewUrlStripper.Replace(path, "-"); var trimmedPath = strippedPath.TrimEnd('/'); var pathWithExtension = trimmedPath + ".jpg"; return MvcHtmlString.Create(helper.AbsoluteAction(pathWithExtension)); }
public ActionResult PasswordRecovery(PasswordRecoveryViewModel model) { if (ModelState.IsValid) { var sessionId = _resetPasswordService.SetResetPasswordSession(model); CommitProviderInstance.Commit(); var urlHelper = new UrlHelper(this.Request.RequestContext); model.ChangePasswordUrl = urlHelper.AbsoluteAction(NameHelper.ResetPassword.ChangePassword, NameHelper.ResetPassword.Controller, new { area = "", sessionId = sessionId }); _taskManager.ScheduleResetPasswordNotification(model.Email, model.ChangePasswordUrl); ViewBag.ShowCofirmation = true; } return View(model); }
public ActionResult Rsd(string path) { Logger.Debug("RSD requested"); var blogPath = _rsdConstraint.FindPath(path); if (blogPath == null) return HttpNotFound(); BlogPart blogPart = _blogService.Get(blogPath); if (blogPart == null) return HttpNotFound(); const string manifestUri = "http://archipelago.phrasewise.com/rsd"; var urlHelper = new UrlHelper(ControllerContext.RequestContext, _routeCollection); var url = urlHelper.AbsoluteAction("", "", new { Area = "XmlRpc" }); var options = new XElement( XName.Get("service", manifestUri), new XElement(XName.Get("engineName", manifestUri), "Orchard CMS"), new XElement(XName.Get("engineLink", manifestUri), "http://orchardproject.net"), new XElement(XName.Get("homePageLink", manifestUri), "http://orchardproject.net"), new XElement(XName.Get("apis", manifestUri), new XElement(XName.Get("api", manifestUri), new XAttribute("name", "MetaWeblog"), new XAttribute("preferred", true), new XAttribute("apiLink", url), new XAttribute("blogID", blogPart.Id)))); var doc = new XDocument(new XElement( XName.Get("rsd", manifestUri), new XAttribute("version", "1.0"), options)); Response.Cache.SetCacheability(HttpCacheability.NoCache); return Content(doc.ToString(), "text/xml"); }
private XRpcArray MetaWeblogGetUserBlogs(UrlHelper urlHelper, string appkey, string userName, string password) { var user = _membershipService.ValidateUser(userName, password); _authorizationService.CheckAccess(StandardPermissions.AccessFrontEnd, user, null); var array = new XRpcArray(); foreach (var blog in _blogService.Get()) { array.Add(new XRpcStruct() .Set("url", urlHelper.AbsoluteAction(() => urlHelper.Blog(blog.Slug))) .Set("blogid", blog.Id) .Set("blogName", blog.Name)); } return array; }
private XRpcArray MetaWeblogGetUserBlogs(UrlHelper urlHelper, string userName, string password) { IUser user = ValidateUser(userName, password); XRpcArray array = new XRpcArray(); foreach (BlogPart blog in _blogService.Get()) { // User needs to at least have permission to edit its own blog posts to access the service if (_authorizationService.TryCheckAccess(Permissions.EditBlogPost, user, blog)) { BlogPart blogPart = blog; array.Add(new XRpcStruct() .Set("url", urlHelper.AbsoluteAction(() => urlHelper.Blog(blogPart))) .Set("blogid", blog.Id) .Set("blogName", blog.Name)); } } return array; }
public static string GetDetailFullUrl(this Rental rental, UrlHelper urlHelper) { if (rental == null || urlHelper == null) return null; return urlHelper.AbsoluteAction(MVC.Rental.ActionNames.Detail, MVC.Rental.Name, new { id = rental.Id }); }
private void RequestEmailChange(UserModel viewModel, UrlHelper helper, User user) { string originalPendingEmail = user.PendingEmail; if (viewModel.PendingEmail != user.EmailAddress) { viewModel.CopyTo(user); string actionEndpoint = helper.AbsoluteAction("ConfirmEmail", "Account"); Uri confirmationEndpoint = new Uri(actionEndpoint); EmailConfirmationManager.Request(user, confirmationEndpoint); } else { viewModel.CopyTo(user); } }
private static XRpcStruct CreateBlogStruct( BlogPostPart blogPostPart, UrlHelper urlHelper) { var url = urlHelper.AbsoluteAction(() => urlHelper.BlogPost(blogPostPart)); var blogStruct = new XRpcStruct() .Set("postid", blogPostPart.Id) .Set("title", blogPostPart.Title) .Set("wp_slug", blogPostPart.Slug) .Set("description", blogPostPart.Text) .Set("link", url) .Set("permaLink", url); if (blogPostPart.PublishedUtc != null) { blogStruct.Set("dateCreated", blogPostPart.PublishedUtc); blogStruct.Set("date_created_gmt", blogPostPart.PublishedUtc); } return blogStruct; }
public ActionResult ContactUs(ContactUsViewModel model) { if (User.Identity.IsAuthenticated) ModelState.Remove("CaptchaAnswer"); if (!ModelState.IsValid) { return View(model); } var urlHelper = new UrlHelper(this.Request.RequestContext); if (User.Identity.IsAuthenticated) { if (SecurityContext.CurrentUser.HasUserAnyRoles(RoleType.DvsAdmin, RoleType.DvsSuperAdmin)) { model.UserDetailsUrl = urlHelper.AbsoluteAction("UserDetails", "DVSViewEdit", new { area = "UserManagement", Id = SecurityContext.CurrentUser.Id }); } else if (SecurityContext.CurrentUser.HasUserAnyRoles(RoleType.Appraiser, RoleType.AppraisalCompanyAdmin, RoleType.CompanyAdminAndAppraiser)) { model.UserDetailsUrl = urlHelper.AbsoluteAction("Index", "AppraiserProfile", new { area = "Appraiser", userId = SecurityContext.CurrentUser.Id }); } _taskManager.ScheduleContactUsFromLoggedUserNotification( SecurityContext.CurrentUser.Email, model.Email, model.Message, model.PhoneNumber, model.Name, model.UserDetailsUrl ); } else { _taskManager.ScheduleContactUsFromAnonymNotification( model.Email, model.Message, model.PhoneNumber, model.Name, model.CompanyName); } ViewBag.ConfirmMessage = string.Format(Constants.ConfirmMessages.ContactUsSuccessMessage, model.Name); return View(model); }
public void Execute(Orchard.Core.Feeds.Models.FeedContext context) { var idValue = context.ValueProvider.GetValue("id"); var connectorValue = context.ValueProvider.GetValue("connector"); var limitValue = context.ValueProvider.GetValue("limit"); var limit = 20; if (limitValue != null) { limit = (int)limitValue.ConvertTo(typeof(int)); } var id = (int)idValue.ConvertTo(typeof(int)); var connectorName = (string)connectorValue.ConvertTo(typeof(string)); var item = Services.ContentManager.Get(id); var socket = item.As<SocketsPart>(); var connectors = socket.Sockets[connectorName].Connectors.List( q => q.ForPart<CommonPart>().OrderBy<CommonPartRecord>(c => c.CreatedUtc), q=>q.ForPart<ConnectorPart>().Slice(0,limit)); var site = Services.WorkContext.CurrentSite; var url = new UrlHelper(_requestContext); if (context.Format == "rss") { var link = new XElement("link"); context.Response.Element.SetElementValue("title", GetTitle(item.GetTitle(), site)); context.Response.Element.Add(link); context.Response.Element.SetElementValue("description", item.GetBody()); context.Response.Contextualize(requestContext => link.Add(url.AbsoluteAction(()=>url.ItemDisplayUrl(item)))); } else { context.Builder.AddProperty(context, null, "title", GetTitle(item.GetTitle(), site)); context.Builder.AddProperty(context, null, "description", item.GetBody()); context.Response.Contextualize(requestContext => context.Builder.AddProperty(context, null, "link", url.AbsoluteAction(() => url.ItemDisplayUrl(item)))); } foreach (var child in connectors) { context.Builder.AddItem(context, child.RightContent.ContentItem); } }
private static XRpcStruct CreateBlogStruct( BlogPostPart blogPostPart, UrlHelper urlHelper) { var url = urlHelper.AbsoluteAction(() => urlHelper.ItemDisplayUrl(blogPostPart)); if (blogPostPart.HasDraft()) { url = urlHelper.AbsoluteAction("Preview", "Item", new { area = "Contents", id = blogPostPart.ContentItem.Id }); } var blogStruct = new XRpcStruct() .Set("postid", blogPostPart.Id) .Set("title", HttpUtility.HtmlEncode(blogPostPart.Title)) .Set("description", blogPostPart.Text) .Set("link", url) .Set("permaLink", url); blogStruct.Set("wp_slug", blogPostPart.As<IAliasAspect>().Path); if (blogPostPart.PublishedUtc != null) { blogStruct.Set("dateCreated", blogPostPart.PublishedUtc); blogStruct.Set("date_created_gmt", blogPostPart.PublishedUtc); } return blogStruct; }
private static string get_link_with_route_data(HtmlHelper html, int page, bool absolute = true) { var urlHelper = new UrlHelper(html.ViewContext.RequestContext); var action = html.ViewContext.Controller.ValueProvider.GetValue("action").RawValue.ToString(); var controller = html.ViewContext.Controller.ValueProvider.GetValue("controller").RawValue.ToString(); var routeData = new RouteValueDictionary(html.ViewContext.RouteData.Values); if (page != 1) { routeData["page"] = page; } else { routeData.Remove("page"); } routeData.Remove("action"); routeData.Remove("controller"); if (absolute) { return urlHelper.AbsoluteAction(action, controller, routeData); } else { return urlHelper.Action(action, controller, routeData); } }
private static XRpcStruct CreateBlogStruct(BlogPost blogPost, UrlHelper urlHelper) { var url = urlHelper.AbsoluteAction(() => urlHelper.BlogPost(blogPost)); return new XRpcStruct() .Set("postid", blogPost.Id) .Set("dateCreated", blogPost.CreatedUtc) .Set("title", blogPost.Title) .Set("wp_slug", blogPost.Slug) .Set("description", blogPost.Text) .Set("link", url) .Set("permaLink", url); }
public static string GetDetailFullUrl(this Localisation loc, UrlHelper urlHelper, string culture = null) { if (loc == null || urlHelper == null) return null; if(string.IsNullOrEmpty(culture)) { culture = CultureInfo.CurrentCulture.ToString().Substring(0, 2); } string typeStr = Localisation.GetLocalisationSeoType(loc.TypeValue); var type = MiscHelpers.GetSeoString(typeStr); var name = MiscHelpers.GetSeoString(loc.GetFullName()); return urlHelper.AbsoluteAction(MVC.Localisation.ActionNames.Details, MVC.Localisation.Name, new { type = type, id = loc.ID, name = name, area = "", culture = culture }); }
public virtual ActionResult Register(RegisterModel model, string myCaptcha, string attempt) { //check capatcha if (!CaptchaHelper.VerifyAndExpireSolution(HttpContext, myCaptcha, attempt)) { ModelState.AddModelError("attempt", Worki.Resources.Validation.ValidationString.VerificationLettersWrong); } //check model validity else if (ModelState.IsValid) { // Tentative d'inscription de l'utilisateur bool createStatusSuccess = false; bool addMemberDataSuccess = false; string error = string.Empty; string field = string.Empty; MembershipCreateStatus createStatus = MembershipCreateStatus.UserRejected; try { var context = ModelFactory.GetUnitOfWork(); var mRepo = ModelFactory.GetRepository<IMemberRepository>(context); var fromDB = mRepo.GetMember(model.Email); if (fromDB != null) { error = Worki.Resources.Validation.ValidationString.UsernameExistForThisMail; field = "Email"; throw new Exception(error); } createStatus = _MembershipService.CreateUser(model.Email, model.Password, model.Email); createStatusSuccess = createStatus == MembershipCreateStatus.Success; if (!createStatusSuccess) { error = AccountValidation.ErrorCodeToString(createStatus); throw new Exception(error); } //add memberData context = ModelFactory.GetUnitOfWork(); mRepo = ModelFactory.GetRepository<IMemberRepository>(context); var created = mRepo.GetMember(model.Email); created.MemberMainData = model.MemberMainData; context.Commit(); addMemberDataSuccess = true; } catch (Exception ex) { _Logger.Error(ex.Message); if (string.IsNullOrEmpty(error)) error = Worki.Resources.Views.Account.InscriptionString.ErrorSave; } if (createStatusSuccess && addMemberDataSuccess) { //add them to private beta role var context = ModelFactory.GetUnitOfWork(); var mRepo = ModelFactory.GetRepository<IMemberRepository>(context); var member = mRepo.GetMember(model.Email); //send mail to activate the account try { var urlHelper = new UrlHelper(ControllerContext.RequestContext); var activationLink = urlHelper.AbsoluteAction(MVC.Account.ActionNames.Activate, MVC.Account.Name, new { userName = member.Email, key = member.EmailKey }); TagBuilder link = new TagBuilder("a"); link.MergeAttribute("href", activationLink); link.InnerHtml = activationLink; var activateMailContent = string.Format(Worki.Resources.Email.Activation.ActivationContent, link.ToString(), member.Email); var activateMail = _EmailService.PrepareMessageFromDefault(new MailAddress(member.Email, member.MemberMainData.FirstName), Worki.Resources.Email.Activation.ActivationSubject, WebHelper.RenderEmailToString(member.MemberMainData.FirstName, activateMailContent)); _EmailService.Deliver(activateMail); } catch (Exception ex) { _Logger.Error(ex.Message); } TempData[MiscHelpers.TempDataConstants.Info] = Worki.Resources.Views.Account.AccountString.ConfirmationMail; return RedirectToAction(MVC.Home.Index()); } else { ModelState.AddModelError(field, error); } } // Si nous sommes arrivés là, quelque chose a échoué, réafficher le formulaire ViewData["PasswordLength"] = _MembershipService.MinPasswordLength; return View(model); }