关于利用浏览器缓存有几个问题,但我没有找到任何有助于在ASP.NET应用程序中执行此操作的内容.谷歌的Pagespeed告诉这是性能最大的问题.到目前为止,我在我的web.config中这样做了:
<system.webServer>
<staticContent>
<!--<clientCache cacheControlMode="UseExpires"
httpExpires="Fri, 24 Jan 2014 03:14:07 GMT" /> -->
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.24:00:00" />
</staticContent>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
评论代码有效.我可以将expire header设置为将来某个特定时间,但我无法设置cacheControlMaxAge从现在开始静态内容的缓存天数.这是行不通的.我的问题是:
我怎样才能做到这一点?我知道有可能只为特定的文件夹设置缓存,这是一个很好的解决方案,但它也不起作用.应用程序托管在Windows Server 2012上,在IIS8上,应用程序池设置为经典.
在web配置中设置此代码后,我的页面速度为72(之前为71).没有缓存50个文件.(现在49)我想知道为什么,我只是意识到一个文件实际上是缓存的(svg文件).不幸的是png和jpg文件没有.这是我的web.config
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="exceptionManagement" type="Microsoft.ApplicationBlocks.ExceptionManagement.ExceptionManagerSectionHandler,Microsoft.ApplicationBlocks.ExceptionManagement" />
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E34" requirePermission="false" allowDefinition="Everywhere" />
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
<section name="errorMail" requirePermission="false" type="Elmah.ErrorMailSectionHandler, Elmah" />
<section name="errorFilter" requirePermission="false" type="Elmah.ErrorFilterSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<exceptionManagement mode="off">
<publisher …Run Code Online (Sandbox Code Playgroud) 我想将我的Razor视图用作发送电子邮件的某种模板,因此我想在视图中"保存"我的模板,将其作为字符串读入控制器,执行一些必要的替换,然后发送它.
我有适用的解决方案:我的模板作为HTML页面托管在某处,但我想把它放到我的应用程序中(即在我的视图中).我不知道如何在我的控制器中读取视图作为字符串.
我尝试了这个
@Html.EditorFor(model => model.Name, " ", new { data_bind = "value:firstName" });
和其他可能的重叠,但它们似乎都没有工作.
其余代码:
<script type="text/javascript">
$(document).ready(function () {
function AppViewModel() {
this.firstName = ko.observable("");
this.lastName = ko.observable("");
}
ko.applyBindings(new AppViewModel());
});
Run Code Online (Sandbox Code Playgroud)
Http/2在服务器上启用,昨天我注意到在Iphone(IOS 10.2)上没有加载一些错误的资源:failed to load resource:connecting to server is not possible.当我将Iphone连接到Mac时,控制台中没有错误,但只是因为某些请求导致错误导致错误.有趣的是,未加载的资源是真实域的子域(CNAME是正确的).网站位于https上.服务器是Windows服务器2016.
编辑: 我们解决了这个子域问题,但仍有来自同一域的请求没有响应任何响应.
我知道当通过https加载资源时,IOS> 9.3支持http/2但是那些不工作的资源不属于该域的东西可以帮助解决这个问题,但我不知道如何.
我知道可能问题与http/2协议有关,因为我的android原生应用程序也停止了错误: java.io.IOException: stream was reset: PROTOCOL_ERROR .我通过强制我的应用程序使用http/1解决了这个问题.现在有效.但是如何解决iphone safari问题呢?
我正在使用ASP.NET Web Forms作为后端(从我使用的ASP.NET 4.6开始支持http2).
如果其他人尝试iframe我的网站,他们会收到错误"拒绝在框架中显示,因为它将'X-Frame-Options'设置为'SAMEORIGIN'".他们是否必须改变某些东西,或者我或两者都改变?我发现有X-Frame-Options的选项:SAMEORIGIN,DENY,并且只允许一个站点.配置:IIS8,ASP.NET MVC.是否有任何全局设置允许其他人为我的网站设置iframe?
我用render()方法制作了自己的表单组件,如下所示:
render() {
return (
<form onSubmit={this.onSubmit} ref={(c)=>this._form=c}>
{this.props.children}
</form>
)
}
Run Code Online (Sandbox Code Playgroud)
请注意,子项在此处呈现为{this.props.children},因此用户可以像这样使用此组件:
<Form onSubmit={this.submit} >
<Input name={"name"} id="name" labelName="Ime" placeholder="Unesite ime" type="text" >
<Validation rule="required" message="Ovo je obavezno polje"/>
</Input>
<Input name={"email"} id="email" labelName="Email" placeholder="Unesite email adresu" type="text" >
<Validation rule="required" message="Ovo je obavezno polje"/>
<Validation rule="email" message="Ovo je nije valjana email adresa"/>
</Input>
<button type="submit" value="Pošalji" >Pošalji</button>
</Form>
Run Code Online (Sandbox Code Playgroud)
我想检查每个Input组件的状态(以获得其有效性)onSubmitMethod().
checkValidity() {
var sefl = this;
this.props.children.map((child) => {
if (child.type.name === "Input") …Run Code Online (Sandbox Code Playgroud) 我阅读了很多关于客户端应该关闭连接的文章,client.Close()因此WCF默认限制不会被超过.事实上,我有WCF WebGet操作,基本上只返回一个图像.
[ServiceContract(SessionMode = SessionMode.NotAllowed)]
[ValidationBehavior]
public interface IImagesService
{
[OperationContract(Name = "ImagesGet4")]
[WebGet(UriTemplate = "/Image/{partner}/{id}/{image}_{width}_{height}.jpg")]
Stream ImagesGet2(string partner, string id, string image, string width, string height);
}
Run Code Online (Sandbox Code Playgroud)
在这种情况下,客户端是浏览器,无论我使用wcf配置做什么都无济于事.maxConnections,maxReceivedMessageSize,maxBytesPerRead 很多其他参数都被淘汰出局,但仍然没有运气.
编辑:
这是附加代码:
ImageGet服务调用的方法:
public Stream ImagesGet(string partner, string id, string image, string width = null, string height = null)
{
WSData.EventLogs.MinimalEventSource.Log.ClientIp("");
WSData.EventLogs.MinimalEventSource.Log.ServicePath("");
WSData.EventLogs.MinimalEventSource.Log.Message( DateTime.Now + " | " + partner );
bool cache;
var images = new Images();
var stream = images.ImagesGetStream(out cache, partner, id, image, …Run Code Online (Sandbox Code Playgroud) 在表单中,我有两个输入日期,StartDate输入和结束日期输入.我也有datepicker实现,
$("#StartDate").datepicker();
Run Code Online (Sandbox Code Playgroud)
datepicker格式化它像:02/27/2013,我不喜欢,但没关系.
我想在将它放入序列化数组之前解析日期.这是一个很好的方法吗?如果这是我怎么能达到这个目的?
如何完成End Date inut比Start That更大,并且不允许oppsoite文件提交?
我正在尝试使用 3 列制作简单的 GridLayout,但是虽然我得到了 3 列,但行之间却出现了奇怪的间隙。所以,我在一行中得到 3 个图像而不是一行是空的(它似乎具有与 abov 行高度匹配的高度(有图像),然后是 3 个图像的行,而不是奇怪的间隙......等等。我预计不会得到比空白差距。如何消除这个空白差距?试图在回收站视图上将 wrap_content 设置为 layout_height,而片段没有帮助。这是我的代码:
final GridLayoutManager layoutManager = new GridLayoutManager(this,3);
layoutManager.setOrientation(LinearLayoutManager.VERTICAL);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setAdapter(adapter);
Run Code Online (Sandbox Code Playgroud)
这是活动的xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
tools:context="com.adriagate.adriagateonlineandroid.activities.ImagesActivity">
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/fragmentImagesHeader"
android:name="com.adriagate.adriagateonlineandroid.fragments.ImagesHeader"
tools:layout="@layout/fragment_images_header" android:layout_width="match_parent"
android:layout_height="match_parent" >
</fragment>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:id="@+id/fragmentImagesGrid"
android:name="com.adriagate.adriagateonlineandroid.fragments.ImagesList"
tools:layout="@layout/fragment_images_list" android:layout_width="match_parent"
android:layout_height="wrap_content" >
</fragment>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
请注意,此布局有一个名为 fragmentImagesGrid 的重要片段,它具有以下布局:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.adriagate.adriagateonlineandroid.fragments.ImagesList">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view_images"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:listitem="@layout/recycler_view_images_one_row"
>
Run Code Online (Sandbox Code Playgroud)
</FrameLayout>
Run Code Online (Sandbox Code Playgroud)
这是回收器视图中一个元素的布局:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content" …Run Code Online (Sandbox Code Playgroud) 我有这个功能:
$("#btn").click(function(e,someOtherArguments)
{ //some code
e.stopPropagation();});
Run Code Online (Sandbox Code Playgroud)
它工作,但如果我已命名函数我不能使用,e因为它是未定义的.
var namedFunction= function(e,someOtherArguments)
{
//some code
e.stopPropagation();
}
$("#btn").click(namedFunction(e,someOtherArguments));
Run Code Online (Sandbox Code Playgroud)
我想使用它,namedFunction因为有几个按钮使用它.
c# ×3
javascript ×3
asp.net ×2
asp.net-mvc ×2
iis ×2
.net ×1
android ×1
caching ×1
date ×1
datepicker ×1
http2 ×1
httphandler ×1
https ×1
iframe ×1
ios ×1
jquery ×1
knockout.js ×1
razor ×1
reactjs ×1
safari ×1
wcf ×1
web-config ×1