本文整理汇总了C#中System.Web.Mvc.UrlHelper.RouteIdUrl方法的典型用法代码示例。如果您正苦于以下问题:C# UrlHelper.RouteIdUrl方法的具体用法?C# UrlHelper.RouteIdUrl怎么用?C# UrlHelper.RouteIdUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Mvc.UrlHelper
的用法示例。
在下文中一共展示了UrlHelper.RouteIdUrl方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendPingback
public virtual PingbackResult SendPingback(AtomEntry entry, Uri pingUrl, Uri pageUrl)
{
LogService.Info("TrackbackService.SendPingback entryId={0} pingUrl={1} pageUrl={2}", entry.Id, pingUrl, pageUrl);
try
{
var url = new UrlHelper(Container.GetInstance<RequestContext>());
using (WebClient client = new WebClient())
{
string response = client.UploadString(pingUrl,
new XElement("methodCall",
new XElement("methodName", "pingback.ping"),
new XElement("params",
new XElement("param",
new XElement("value",
new XElement("string", url.RouteIdUrl("BlogEntry", entry.Id, AbsoluteMode.Force)))),
new XElement("param",
new XElement("value",
new XElement("string", pageUrl))))).ToString());
return new PingbackResult()
{
Xml = XElement.Parse(response.Substring(response.IndexOf('<')))
};
}
}
catch (Exception ex)
{
LogService.Error(ex);
PingbackResult r = new PingbackResult();
r.SetFault(0, ex.Message);
return r;
}
}
示例2: GetTrackbackMetadata
public string GetTrackbackMetadata(Id entryId)
{
var url = new UrlHelper(Container.GetInstance<RequestContext>());
AtomEntry entry = AtomEntryRepository.GetEntry(entryId);
string metadata = string.Empty;
metadata += "\n<!--\n<rdf:RDF xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\"\nxmlns:dc=\"http://purl.org/dc/elements/1.1/\"\nxmlns:trackback=\"http://madskills.com/public/xml/rss/module/trackback/\">\n";
metadata += string.Format("<rdf:Description\nrdf:about=\"{0}\"\ndc:identifier=\"{1}\"\ndc:title=\"{2}\"\ntrackback:ping=\"{3}\" />\n</rdf:RDF>\n-->\n\n",
url.RouteIdUrl("BlogEntry", entry.Id, AbsoluteMode.Force), entry.Id, entry.Title.ToString(), url.RouteIdUrl("Trackback", entry.Id, AbsoluteMode.Force));
return metadata;
}
示例3: SendTrackback
public virtual TrackbackResult SendTrackback(AtomEntry entry, Uri pingUrl)
{
LogService.Info("TrackbackService.SendTrackback entryId={0} pingUrl={1}", entry.Id, pingUrl);
try
{
var url = new UrlHelper(Container.GetInstance<RequestContext>());
NameValueCollection data = new NameValueCollection();
data.Add("title", entry.Title.ToString());
data.Add("url", url.RouteIdUrl("BlogEntry", entry.Id, AbsoluteMode.Force));
data.Add("excerpt", entry.Text.ToStringPreview(96));
data.Add("blog_name", AppService.GetCollection(entry.Id).Title.ToString());
using (WebClient client = new WebClient())
{
string result = Encoding.Default.GetString(client.UploadValues(pingUrl, data));
return new TrackbackResult()
{
Xml = XElement.Parse(result.Substring(result.IndexOf('<')))
};
}
}
catch (Exception ex)
{
LogService.Error(ex);
return new TrackbackResult()
{
Error = true,
Message = ex.Message
};
}
}