当前位置: 首页>>代码示例>>C#>>正文


C# UrlHelper.RouteIdUri方法代码示例

本文整理汇总了C#中System.Web.Mvc.UrlHelper.RouteIdUri方法的典型用法代码示例。如果您正苦于以下问题:C# UrlHelper.RouteIdUri方法的具体用法?C# UrlHelper.RouteIdUri怎么用?C# UrlHelper.RouteIdUri使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Mvc.UrlHelper的用法示例。


在下文中一共展示了UrlHelper.RouteIdUri方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SetLinks

    protected void SetLinks(AtomEntry e)
    {
      LogService.Debug("AnnotateService.SetLinks entryId={0}", e.Id);
      var links = e.Links.ToList();
      var url = new UrlHelper(Container.GetInstance<RequestContext>());
      //atom threading extension
      if (e.InReplyTo != null)
      {
        e.InReplyTo.Href = url.RouteIdUri("AtomPubResource", e.InReplyTo.Ref, AbsoluteMode.Force);
        links.Merge(new AtomLink
        {
          Rel = "related",
          Type = "text/html",
          Href = url.RouteIdUri("AtomPubResource", e.InReplyTo.Ref, AbsoluteMode.Force)
        });
      }

      //atom threading extension
      links.Merge(new AtomLink
      {
        Href = url.RouteIdUri("AnnotateEntryAnnotationsFeed", e.Id, AbsoluteMode.Force),
        Rel = "replies",
        Type = Atom.ContentType,
        Count = e.Total,
        Updated = DateTimeOffset.UtcNow
      });
      e.Links = links;
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:28,代码来源:AnnotateService.cs

示例2: SetLinks

    protected void SetLinks(AtomEntry e)
    {
        if (!new BlogAppCollection(AppService.GetCollection(e.Id)).BloggingOn) return;
      LogService.Debug("BlogService.SetLinks entryId={0}", e.Id);
      var links = e.Links.ToList();
      var url = new UrlHelper(Container.GetInstance<RequestContext>());
      if (e.InReplyTo == null)
      {
          links.Merge(new AtomLink()
          {
              Rel = "alternate",
              Type = "text/html",
              Href = url.RouteIdUri("BlogEntry", e.Id, AbsoluteMode.Force)
          });
      }
      else // annotation
      {
          links.Merge(new AtomLink()
          {
              Rel = "alternate",
              Type = "text/html",
              Href = new System.Uri(url.RouteIdUri("BlogEntry", e.InReplyTo.Ref, AbsoluteMode.Force).ToString() + "#" + e.Id.ToWebId())
          });
          e.InReplyTo.Href = url.RouteIdUri("BlogEntry", e.InReplyTo.Ref, AbsoluteMode.Force);
          links.Merge(new AtomLink
          {
              Rel = "related",
              Type = "text/html",
              Href = url.RouteIdUri("BlogEntry", e.InReplyTo.Ref, AbsoluteMode.Force)
          });

          if (AnnotateService.GetAnnotationState(AppService.GetCollection(e.Id), e.Id) == AnnotationState.On)
          {
              links.Merge(new AtomLink
              {
                  Rel = "reply",
                  Type = "text/html",
                  Href = new System.Uri(url.RouteIdUri("BlogEntry", e.InReplyTo.Ref, AbsoluteMode.Force).ToString() + "#addcommentform")
              });
          }
      }
      e.Links = links;
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:43,代码来源:BlogService.cs

示例3: GetRaterModel

 public RaterModel GetRaterModel(string ip, UrlHelper url)
 {
   return new RaterModel()
   {
     PostHref = url.RouteIdUri("RaterRateEntry", Theme.Id),
     EntryId = Theme.Id,
     Rating = Theme.Rating,
     RatingCount = Theme.RatingCount,
     CanRate = false
   };
 }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:11,代码来源:AdminThemeModel.cs

示例4: Annotate

    public virtual AtomEntry Annotate(Id entryId, AtomEntry entry, string slug)
    {
      LogService.Info("AnnotateService.Annotate entryId={0} slug={1}", entryId, slug);

      //authorization
      if (!AuthorizeService.IsAuthorized(GetUser(), entryId.ToScope(), AuthAction.Annotate))
        throw new UserNotAuthorizedException(GetUser().Name, AuthAction.Annotate.ToString());

      AppCollection coll = AppService.GetCollection(entryId);

      //make sure type is accepted
      if (!coll.CanAccept(Atom.ContentTypeEntry))
        throw new InvalidContentTypeException(Atom.ContentTypeEntry);

      entry.SetNamespaces(); //TODO: is there a better place for this?

      //build id onto parent's id
      AtomEntry parent = AtomPubService.GetEntry(entryId);
      entry.Id = new Id(parent.Id.Owner, parent.Id.Date, parent.Id.Collection, entry.BuildPath(parent.Id.EntryPath, slug));
      
      var url = new UrlHelper(Container.GetInstance<RequestContext>());
      //this annotation is a reply to the parent entry, TODO: leave off href for later calc based on id?
      entry.InReplyTo = new ThreadInReplyTo()
      {
        Ref = parent.Id,
        Href = parent.IsExternal ? parent.Content.Src : url.RouteIdUri("AtomPubEntry", entry.Id, AbsoluteMode.Force),
        Type = parent.IsExternal ? parent.Content.Type : Atom.ContentTypeEntry
      };

      if (!entry.Published.HasValue) entry.Published = DateTimeOffset.UtcNow;
      entry.Updated = DateTimeOffset.UtcNow;
      entry.Edited = DateTimeOffset.UtcNow;

      if (entry.Authors.Count() == 0) entry.SetPerson(AuthorizeService, true);

      //entry.IdChanged += (e) => e.UpdateLinks(UrlHelper.RouteIdUri);

      //OnAnnotate(parent, entryId, entry, slug);
      if (AnnotatingEntry != null) AnnotatingEntry(entryId, entry, slug);

      if (entry.Authors.Count() == 0 || entry.Authors.First().Name == null)
        throw new AnnotationNotAllowedException(entry.Id, entry.AnnotationType, "the author cannot be determined");

      entry = AtomEntryRepository.CreateEntry(entry);
      if (EntryAnnotated != null) EntryAnnotated(entry);
      return entry;
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:47,代码来源:AnnotateService.cs

示例5: SetLinks

    protected void SetLinks(AtomFeed feed)
    {
      LogService.Debug("AtomPubService.SetLinks collectionId={0}", feed.Id);
      if (feed.Links == null) feed.Links = new List<AtomLink>();
      var links = feed.Links.ToList();

      var url = new UrlHelper(Container.GetInstance<RequestContext>());
      links.Merge(new AtomLink()
      {
        Rel = "service",
        Type = Atom.ContentTypeService,
        Href = url.RouteUriEx("AtomPubService", AbsoluteMode.Force)
      });
      if (feed.Id != null && feed.Id.Scheme == "tag")
      {
        links.Merge(new AtomLink()
        {
          Rel = "self",
          Type = Atom.ContentTypeFeed,
          Href = url.RouteIdUri("AtomPubFeed", feed.Id, AbsoluteMode.Force)
        });
        links.Merge(new AtomLink()
        {
          Rel = "alternate",
          Type = "text/html",
          Href = url.RouteIdUri("AtomPubCollectionIndex", feed.Id, AbsoluteMode.Force)
        });
      }
      feed.Links = links;
      foreach (AtomEntry entry in feed.Entries) SetLinks(entry);
      if (SettingFeedLinks != null) SettingFeedLinks(feed);
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:32,代码来源:AtomPubService.cs

示例6: ReceiveTrackback

    public virtual TrackbackResult ReceiveTrackback(Id entryId, string title, string excerpt,
        string url, string blogName, string ip, Uri referrer)
    {
      LogService.Info("TrackbackService.ReceiveTrackback entryId={0} title={1} url={2}", entryId, title, url);

      if (!IsEnabled(AtomEntryRepository.GetEntry(entryId)))
        return new TrackbackResult() { Error = true, Message = "Trackbacks are disabled." };

      try
      {
        string page = string.Empty;
        string contentType = "text/html";
        using (WebClient client = new WebClient())
        {
          page = client.DownloadString(url);
          if (client.ResponseHeaders["Content-Type"] != null)
            contentType = client.ResponseHeaders["Content-Type"];
        }

        var uh = new UrlHelper(Container.GetInstance<RequestContext>());
        //validate page has a link back
        if (!ContainsLink(page, uh.RouteIdUri("BlogEntry", entryId, AbsoluteMode.Force)))
          throw new AnnotationNotAllowedException(entryId, "trackback", "it does not link back");

        AtomEntry trackback = new AtomEntry();

        //content
        trackback.Content = new AtomContent() { Src = new Uri(url), Type = contentType };

        //title
        if (title == null) title = WebHelper.ExtractTitleForPage(page);
        if (title == null) title = "Trackback";
        trackback.Title = new AtomTitle() { Text = title };

        //summary
        if (excerpt == null) excerpt = WebHelper.ExtractDescriptionForPage(page);
        trackback.Summary = new AtomSummary() { Text = excerpt };

        //author
        trackback.Authors = new List<AtomPerson>() { new AtomAuthor() 
                { 
                    Name = blogName == null ? string.Empty : blogName,
                    Uri = referrer
                } };

        //add extension data?
        trackback.SetValue<string>(Atom.SvcNs + "ip", ip);
        trackback.AnnotationType = "trackback";

        AnnotateService.Annotate(entryId, trackback, null);

        return new TrackbackResult() { Error = false };
      }
      catch (Exception ex)
      {
        LogService.Error(ex);
        return new TrackbackResult() { Error = true, Message = ex.Message };
      }
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:59,代码来源:TrackbackService.cs


注:本文中的System.Web.Mvc.UrlHelper.RouteIdUri方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。