首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >允许AtomPub ASPNET服务器中的图像

允许AtomPub ASPNET服务器中的图像
EN

Stack Overflow用户
提问于 2013-05-21 03:20:32
回答 1查看 289关注 0票数 0

我正在尝试使用ASP.NET WEB API创建Atompub服务,一切都很好,但是当我尝试从Windows Live Writer发布任何图像时,我得到一个错误消息"The blog get allow the image load“我正在读取ietf doc

我的服务控制器代码:

代码语言:javascript
复制
public class ServicesController : ApiController
{
    public HttpResponseMessage Get()
    {
        var serviceDocument = new ServiceDocument();
        var workSpace = new Workspace
        {
            Title = new TextSyndicationContent("Nicoloco Site"),
            BaseUri = new Uri(Request.RequestUri.GetLeftPart(UriPartial.Authority))
        };
        var posts = new ResourceCollectionInfo("Nicoloco Blog",
                                               new Uri(Url.Link("DefaultApi", new { controller = "blogapi" })));
        posts.Accepts.Add("application/atom+xml;type=entry");
        var images = new ResourceCollectionInfo("Images Blog",
                                                new Uri(Url.Link("DefaultApi", new { controller = "images" })));
        images.Accepts.Add("image/png");
        images.Accepts.Add("image/jpeg");
        images.Accepts.Add("image/jpg");
        images.Accepts.Add("image/gif");
        var categoriesUri = new Uri(Url.Link("DefaultApi", new { controller = "tags", format = "atomcat" }));
        var categories = new ReferencedCategoriesDocument(categoriesUri);
        posts.Categories.Add(categories);
        workSpace.Collections.Add(posts);
        workSpace.Collections.Add(images);
        serviceDocument.Workspaces.Add(workSpace);
        var response = new HttpResponseMessage(HttpStatusCode.OK);
        var formatter = new AtomPub10ServiceDocumentFormatter(serviceDocument);
        var stream = new MemoryStream();
        using (var writer = XmlWriter.Create(stream))
        {
            formatter.WriteTo(writer);
        }
        stream.Position = 0;
        var content = new StreamContent(stream);
        response.Content = content;
        response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/atomsvc+xml");
        return response;
    }
}

http GET请求生成以下XML:

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<app:service 
    xmlns:a10="http://www.w3.org/2005/Atom" 
    xmlns:app="http://www.w3.org/2007/app">
    <app:workspace xml:base="http://localhost:53644/">
        <a10:title type="text">Nicoloco Site</a10:title>
        <app:collection href="http://localhost:53644/api/blogapi">
            <a10:title type="text">Nicoloco Blog</a10:title>
            <app:accept>application/atom+xml;type=entry</app:accept>
            <app:categories href="http://localhost:53644/api/tags?format=atomcat" />
        </app:collection>
        <app:collection href="http://localhost:53644/api/images">
            <a10:title type="text">Images Blog</a10:title>
            <app:accept>image/png</app:accept>
            <app:accept>image/jpeg</app:accept>
            <app:accept>image/jpg</app:accept>
            <app:accept>image/gif</app:accept>
        </app:collection>
    </app:workspace>
</app:service>

但是我不能使用这个服务发布图片。

诚挚的问候。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-05-22 23:36:28

我在“类别行”上发现了我的错误,WLW日志文件在这一行显示了一个格式错误的XML错误,我删除了它,一切对我来说都很好……in this博客文章解释了WLW是如何处理图像文件的

如果有人有什么意见..。我将感激不尽

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/16656782

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档