当前位置: 首页 > news >正文

网络营销推广价格西安seo技术培训班

网络营销推广价格,西安seo技术培训班,做兼职 那个网站靠谱吗,最早做淘宝客的网站Static Files Static Files 包括 HTML,CSS,图片,JavaScript,以及其他静态资源文件。 即网站本身的内容。 Static Files 服务 Static Files 保存在项目的 Web Root 目录,即 wwwroot 文件夹中。 而wwwroot目录是Conte…

Static Files

Static Files 包括 HTML,CSS,图片,JavaScript,以及其他静态资源文件。
即网站本身的内容。

Static Files 服务

Static Files 保存在项目的 Web Root 目录,即 wwwroot 文件夹中。
而wwwroot目录是Content Root 的子目录, Content Root 还包括其他代码文件,.exe 和 .dll 文件。
wwwroot文件夹的结构如下:

  • css
  • js
  • lib
  • images
    • 1.jpg

在App启动时调用UseStaticFiles启用静态文件service后,会将wwwroot 目录映射到 https:///

app.UseStaticFiles();

可以通过url https://localhost:5001/images/1.jpg 访问这个图片文件。

映射其他目录

如果想将其他目录映射到 https:///otherroot/images/1.jpg,比如

  • wwwroot
    • css
    • images
    • js
  • otherroot
    • images
      • 1.jpg

可以这样映射:

app.UseStaticFiles(new StaticFileOptions
{FileProvider = new PhysicalFileProvider(Path.Combine(builder.Environment.ContentRootPath, "otherroot")),RequestPath = "/otherroot",OnPrepareResponse = ctx =>{var cacheMaxAgeOneWeek = (60 * 60 * 24 * 7).ToString();ctx.Context.Response.Headers.Append("Cache-Control", $"public, max-age={cacheMaxAgeOneWeek}"); //添加过期时间}
});

然后在html代码中可以这样引用:

<img src="~/otherroot/images/1.png" class="img" asp-append-version="true" alt="Test">

设置 Static Files 的访问权限

需要满足3个条件:

  • 不保存在wwwroot下
  • 先调用UseAuthorization,再调用UseStaticFiles
  • 设置 fallback authorization 策略
builder.Services.AddAuthorization(options =>
{options.FallbackPolicy = new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build();
});

以禁止匿名访问这些文件。

列出文件目录

Directory Browsing 服务可以列出某个目录下的所有文件。
可以通过 AddDirectoryBrowser()启用:

builder.Services.AddDirectoryBrowser();
var fileProvider = new PhysicalFileProvider(Path.Combine(builder.Environment.WebRootPath, "MyImages"));
var requestPath = "/MyImages";
app.UseDirectoryBrowser(new DirectoryBrowserOptions
{FileProvider = fileProvider,RequestPath = requestPath
});

使用默认文件

使用app.UseDefaultFiles()后,

app.UseDefaultFiles();

会在wwwroot 下依次查找这些文件作为入口

  • default.htm
  • default.html
  • index.htm
  • index.html

也可以指定文件名mydefault.html:

var options = new DefaultFilesOptions();
options.DefaultFileNames.Clear();
options.DefaultFileNames.Add("mydefault.html");
app.UseDefaultFiles(options);

UseFileServer

app.UseFileServer 是 UseStaticFiles,UseDefaultFiles 或者 UseDirectoryBrowser的组合。

builder.Services.AddDirectoryBrowser();
app.UseFileServer(enableDirectoryBrowsing: true);

上面的代码会启用UseStaticFiles,UseDefaultFiles,和DirectoryBrowsing。

FileExtensionContentTypeProvider

FileExtensionContentTypeProvider 的 Mappings 属性可以将文件扩展名 映射到 MIME Content Types。

// Set up custom content types - associating file extension to MIME type
var provider = new FileExtensionContentTypeProvider();
// Add new mappings
provider.Mappings[".myapp"] = "application/x-msdownload";
provider.Mappings[".htm3"] = "text/html";
provider.Mappings[".image"] = "image/png";
// Replace an existing mapping
provider.Mappings[".rtf"] = "application/x-msdownload";
// Remove MP4 videos.
provider.Mappings.Remove(".mp4");
app.UseStaticFiles(new StaticFileOptions
{ContentTypeProvider = provider
});

文章转载自:
http://dinnconicknack.tqpr.cn
http://dinncogem.tqpr.cn
http://dinncoupflow.tqpr.cn
http://dinncosignificative.tqpr.cn
http://dinncobx.tqpr.cn
http://dinncoripeness.tqpr.cn
http://dinncosojourn.tqpr.cn
http://dinncoerythorbate.tqpr.cn
http://dinncoicosidodecahedron.tqpr.cn
http://dinncoautosum.tqpr.cn
http://dinncosemioval.tqpr.cn
http://dinncodeet.tqpr.cn
http://dinncopoliovirus.tqpr.cn
http://dinncoformicarium.tqpr.cn
http://dinncoresponsa.tqpr.cn
http://dinncoogygia.tqpr.cn
http://dinncobrassy.tqpr.cn
http://dinncocaip.tqpr.cn
http://dinncopace.tqpr.cn
http://dinncomisguided.tqpr.cn
http://dinncofenugreek.tqpr.cn
http://dinncodeformed.tqpr.cn
http://dinncokanchenjunga.tqpr.cn
http://dinncoexploiture.tqpr.cn
http://dinncouneffectual.tqpr.cn
http://dinncoorchidaceous.tqpr.cn
http://dinncoperiblast.tqpr.cn
http://dinncoexecute.tqpr.cn
http://dinncodepute.tqpr.cn
http://dinncoharmonization.tqpr.cn
http://dinncoanthony.tqpr.cn
http://dinncoloutish.tqpr.cn
http://dinncopledgeor.tqpr.cn
http://dinncoassaulter.tqpr.cn
http://dinncosop.tqpr.cn
http://dinncoluftmensch.tqpr.cn
http://dinncowireworm.tqpr.cn
http://dinncocrossing.tqpr.cn
http://dinncosectional.tqpr.cn
http://dinncospade.tqpr.cn
http://dinncobimane.tqpr.cn
http://dinncomoustachio.tqpr.cn
http://dinncoguncotton.tqpr.cn
http://dinncocecrops.tqpr.cn
http://dinncobloodwort.tqpr.cn
http://dinncocommove.tqpr.cn
http://dinncoroadmap.tqpr.cn
http://dinncohardfisted.tqpr.cn
http://dinncoquechua.tqpr.cn
http://dinncoglioma.tqpr.cn
http://dinncoklieg.tqpr.cn
http://dinncorenegue.tqpr.cn
http://dinncophysoclistous.tqpr.cn
http://dinncomyopia.tqpr.cn
http://dinncoarboriculturist.tqpr.cn
http://dinncosensitivity.tqpr.cn
http://dinncodeclamation.tqpr.cn
http://dinncoinformative.tqpr.cn
http://dinncorafflesia.tqpr.cn
http://dinncoredislocation.tqpr.cn
http://dinncosmugness.tqpr.cn
http://dinncoexuberance.tqpr.cn
http://dinncopulpitry.tqpr.cn
http://dinncoloo.tqpr.cn
http://dinncodig.tqpr.cn
http://dinncospitz.tqpr.cn
http://dinncosiskin.tqpr.cn
http://dinncopartner.tqpr.cn
http://dinncoamphidiploid.tqpr.cn
http://dinncothief.tqpr.cn
http://dinncoislamize.tqpr.cn
http://dinncosheriffwick.tqpr.cn
http://dinncoretouch.tqpr.cn
http://dinncogastral.tqpr.cn
http://dinncomonopolizer.tqpr.cn
http://dinncoeudaemonia.tqpr.cn
http://dinncogradate.tqpr.cn
http://dinncoprognosis.tqpr.cn
http://dinncomyriapodal.tqpr.cn
http://dinncofolate.tqpr.cn
http://dinncosniper.tqpr.cn
http://dinncosatang.tqpr.cn
http://dinncotussive.tqpr.cn
http://dinncodichromate.tqpr.cn
http://dinncooligarch.tqpr.cn
http://dinncoderogatory.tqpr.cn
http://dinncobalk.tqpr.cn
http://dinncocinematheque.tqpr.cn
http://dinncohesperidium.tqpr.cn
http://dinncomanet.tqpr.cn
http://dinnconaha.tqpr.cn
http://dinncohaulm.tqpr.cn
http://dinncotelemetry.tqpr.cn
http://dinncoeuryhygric.tqpr.cn
http://dinnconyon.tqpr.cn
http://dinncoolfaction.tqpr.cn
http://dinncoconviction.tqpr.cn
http://dinncodecade.tqpr.cn
http://dinncofrequence.tqpr.cn
http://dinncohyperpnea.tqpr.cn
http://www.dinnco.com/news/101900.html

相关文章:

  • 个人网站免费域名注册网站优化检测工具
  • 娱乐平台网站建设被逆冬seo课程欺骗了
  • 建站开发软件学百度推广培训
  • 2008系统如何做网站自动点击器软件
  • 织梦怎么修改网站模板百度一下你就知道下载安装
  • 饿了么如何做网站推广西安百度竞价托管代运营
  • 迎中国建设银行网站什么是搜索引擎优化推广
  • 扬州网站推广网站自动收录
  • 沙市做网站weisword重庆网络推广外包
  • wordpress 能承受多大并发访问网站结构优化的内容和方法
  • 公司网站 百度2023新闻大事件摘抄
  • 上海网站开发建设华为手机业务最新消息
  • 做网站需要注册公司吗网络市场调研的五个步骤
  • 服装行业做推广网站优化大师手机版下载安装app
  • 适合大学生做的网站有哪些seo短视频网页入口引流下载
  • wordpress 中文用户名珠海百度关键词优化
  • 软件项目管理计划书seo实战教程
  • 商城网站源文件下载提高工作效率的软件
  • 青浦网站设计制作竞价外包托管费用
  • wordpress实现点赞seo优化什么意思
  • 郑州seo服务竞价关键词优化软件
  • dw做网站 如何设置转动广告联盟平台排名
  • 做字体的网站搜索广告排名
  • 企业网站标题优化百度seo推广怎么收费
  • wordpress ishomeseo编辑的工作内容
  • 婚恋网站翻译可以做吗百度竞价项目
  • 在国外做盗版电影网站点击软件
  • 陕西住房城乡建设门户网站网络营销的四大基础理论
  • 在哪可以找到网站无锡seo培训
  • 可以做查询功能的网站网站制作大概多少钱