我需要为IIS Express添加.woff文件扩展名的新MIME映射.
如果我将以下代码段添加到IIS Express的"applicationhost.config",它可以正常工作:
<staticContent lockAttributes="isDocFooterFileName">
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
...
Run Code Online (Sandbox Code Playgroud)
但我真的想把它添加到我的"web.config"中,这样每个开发人员都不需要在本地更改他们的"applicationhost.config".
所以我再次从"applicationhost.config"文件中删除它,并将以下代码段添加到项目的"web.config"中:
<system.webServer>
...
<staticContent>
<mimeMap fileExtension=".woff" mimeType="font/x-woff" />
</staticContent>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)
不幸的是它似乎没有那样工作,因为当我尝试访问.woff文件时,我最终得到HTTP 404.3错误.
我究竟做错了什么?
如何撤消Mercurial中最后一次意外提交(未推送)的更改?
如果可能的话,首选使用TortoiseHg的方法.
更新
在我的具体案例中,我提交了一个变更集(未推送).然后我从服务器拉出并更新.有了这些新的更新,我决定,我的上次提交已经过时,我不想同步它.所以看起来,这hg rollback并不是我正在寻找的东西,因为它会回滚拉而不是我的提交.
在我的一个控制器动作中,我返回一个非常大JsonResult的填充网格.
我收到以下InvalidOperationException异常:
使用JSON JavaScriptSerializer进行序列化或反序列化时出错.字符串的长度超过maxJsonLength属性上设置的值.
不幸的是,将maxJsonLength属性设置web.config为更高的值不会产生任何影响.
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="2147483644"/>
</webServices>
</scripting>
</system.web.extensions>
Run Code Online (Sandbox Code Playgroud)
我不想把它作为一个字符串传回去,就像这个 SO答案中提到的那样.
在我的研究中,我遇到了这篇博文,其中建议编写自己的ActionResult(例如LargeJsonResult : JsonResult)来绕过这种行为.
这是唯一的解决方案吗?
这是ASP.NET MVC中的错误吗?
我错过了什么吗?
非常感激任何的帮助.
如何C:\Users\User\AppData\Roaming在PowerShell中获取应用程序数据目录(例如)的路径?
在.NET 4中,还可以使用System.Lazy<T>该类编写具有缓存属性的以下代码段.我测量了两种方法的性能,它几乎是一样的.对于为什么我应该使用一个而不是另一个,是否有任何真正的好处或魔力?
缓存属性
public static class Brushes
{
private static LinearGradientBrush _myBrush;
public static LinearGradientBrush MyBrush
{
get
{
if (_myBrush == null)
{
var linearGradientBrush = new LinearGradientBrush { ...};
linearGradientBrush.GradientStops.Add( ... );
linearGradientBrush.GradientStops.Add( ... );
_myBrush = linearGradientBrush;
}
return _myBrush;
}
}
}
Run Code Online (Sandbox Code Playgroud)
懒惰<T>
public static class Brushes
{
private static readonly Lazy<LinearGradientBrush> _myBrush =
new Lazy<LinearGradientBrush>(() =>
{
var linearGradientBrush = new LinearGradientBrush { ...};
linearGradientBrush.GradientStops.Add( ... );
linearGradientBrush.GradientStops.Add( ... );
return linearGradientBrush;
} …Run Code Online (Sandbox Code Playgroud) 无法测试从Windows Vista Business中的.NET代码发送电子邮件.
我正在编写代码,一旦证实,我将迁移到SSIS包.代码是通过电子邮件将错误消息发送到收件人列表.
代码如下,但是当我执行代码时遇到异常.
我创建了一个简单的类来进行邮件...设计可能更好,我在实现更强大的功能,方法等之前测试功能.
namespace LabDemos
{
class Program
{
static void Main(string[] args)
{
Mailer m = new Mailer();
m.test();
}
}
}
namespace LabDemos
{
class MyMailer
{
List<string> _to = new List<string>();
List<string> _cc = new List<string>();
List<string> _bcc = new List<string>();
String _msgFrom = "";
String _msgSubject = "";
String _msgBody = "";
public void test(){
//create the mail message
MailMessage mail = new MailMessage();
//set the addresses
mail.From = new MailAddress("me@domain.com");
//set the …Run Code Online (Sandbox Code Playgroud) 我正在尝试处理WPF应用程序中的用户不活动和活动,以淡入淡出某些内容.经过大量的研究,我决定采用(至少在我看来)非常优雅的解决方案Hans Passant在这里发布.
只有一个缺点:只要光标停留在窗口顶部,PreProcessInput事件就会不断被触发.我有一个全屏应用程序,所以这会杀死它.任何想法如何绕过这种行为将是非常感激的.
public partial class MainWindow : Window
{
readonly DispatcherTimer activityTimer;
public MainWindow()
{
InitializeComponent();
InputManager.Current.PreProcessInput += Activity;
activityTimer = new DispatcherTimer
{
Interval = TimeSpan.FromSeconds(10),
IsEnabled = true
};
activityTimer.Tick += Inactivity;
}
void Inactivity(object sender, EventArgs e)
{
rectangle1.Visibility = Visibility.Hidden; // Update
// Console.WriteLine("INACTIVE " + DateTime.Now.Ticks);
}
void Activity(object sender, PreProcessInputEventArgs e)
{
rectangle1.Visibility = Visibility.Visible; // Update
// Console.WriteLine("ACTIVE " + DateTime.Now.Ticks);
activityTimer.Stop();
activityTimer.Start();
}
}
Run Code Online (Sandbox Code Playgroud)
更新
我可以更好地缩小所描述的行为(请参阅rectangle1.Visibility …
我正在使用ASP.NET MVC 4捆绑和缩小Microsoft.AspNet.Web.Optimization命名空间中的功能(例如@Styles.Render("~/content/static/css")).
我想将它与Windows Azure CDN结合使用.
我考虑编写自定义,BundleTransform但内容尚未优化.
我还研究了在运行时解析和上传优化的流,但这对我来说就像是一个黑客,我真的不喜欢它:
@StylesCdn.Render(Url.AbsoluteContent(
Styles.Url("~/content/static/css").ToString()
));
public static IHtmlString Render(string absolutePath)
{
// get the version hash
string versionHash = HttpUtility.ParseQueryString(
new Uri(absolutePath).Query
).Get("v");
// only parse and upload to CDN if version hash is different
if (versionHash != _versionHash)
{
_versionHash = versionHash;
WebClient client = new WebClient();
Stream stream = client.OpenRead(absolutePath);
UploadStreamToAzureCdn(stream);
}
var styleSheetLink = String.Format(
"<link href=\"{0}://{1}/{2}/{3}?v={4}\" rel=\"stylesheet\" type=\"text/css\" />",
cdnEndpointProtocol, cdnEndpointUrl, cdnContainer, cdnCssFileName, versionHash …Run Code Online (Sandbox Code Playgroud) cdn azure asp.net-mvc-4 bundling-and-minification asp.net-optimization
.net ×4
c# ×4
.net-4.0 ×1
asp.net ×1
asp.net-mvc ×1
azure ×1
cdn ×1
commenting ×1
cryptography ×1
events ×1
exception ×1
hash ×1
iis-express ×1
jsonresult ×1
lazy-loading ×1
liquid ×1
mercurial ×1
mime-types ×1
powershell ×1
scripting ×1
scrypt ×1
ssis ×1
syntax ×1
tortoisehg ×1
wpf ×1