亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為 Autofac 中的嵌套依賴項提供類型化參數

為 Autofac 中的嵌套依賴項提供類型化參數

C#
大話西游666 2022-10-23 16:41:31
使用 .NET Core 包Syncfusion.EJ2.WordEditor.AspNet.Core,我可以將 doc(x) 文件轉換為 sfdt 格式。因此,我使用 Visual Studio 2017 For Mac 使用此包創建了一個新的 .NET Core Web Api 應用程序。using System;using System.Collections.Generic;using System.IO;using System.Linq;using System.Threading.Tasks;using Microsoft.AspNetCore.Http;using Microsoft.AspNetCore.Mvc;using Syncfusion.EJ2.DocumentEditor;namespace SyncfusionConverter.Controllers{    [Route("api/[controller]")]    public class SyncfusionController : Controller    {        [AcceptVerbs("Post")]        public string Import(IFormCollection data)        {            if (data.Files.Count == 0)                return null;            Stream stream = new MemoryStream();            IFormFile file = data.Files[0];            int index = file.FileName.LastIndexOf('.');            string type = index > -1 && index < file.FileName.Length - 1 ?            file.FileName.Substring(index) : ".docx";            file.CopyTo(stream);            stream.Position = 0;            WordDocument document = WordDocument.Load(stream, GetFormatType(type.ToLower()));            string sfdt = Newtonsoft.Json.JsonConvert.SerializeObject(document);            document.Dispose();            return sfdt;        }        internal static FormatType GetFormatType(string format)        {            if (string.IsNullOrEmpty(format))                throw new NotSupportedException("EJ2 DocumentEditor does not support this file format.");            switch (format.ToLower())            {                case ".dotx":                case ".docx":                case ".docm":            }        }    }}我發出 Ajax 請求,以我的 doc(x) 文件作為參數調用此 .Net 方法。執行 loadFile 函數時,我在瀏覽器的控制臺中收到此錯誤:“跨源請求(阻止多源請求):“同源”策略不允許查閱位于https://localhost上的遠程資源:5001/Syncfusion/Import。原因:CORS 請求失敗?!蔽野凑毡窘坛毯湍切?SO 發布Link1 Link2但它不起作用。有什么想法可以解決這個問題嗎?
查看完整描述

1 回答

?
開心每一天1111

TA貢獻1836條經驗 獲得超13個贊

簡短的回答:您不能將參數傳遞給解析鏈中間的東西。

這是 Autofac 文檔中的常見問題解答。


查看完整回答
反對 回復 2022-10-23
  • 1 回答
  • 0 關注
  • 111 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號