我正在尝试使用Twitter引导程序在MVC 4中使用新的捆绑功能,在我看来,像css的字形png文件的路径以某种方式搞砸了.继承我的代码:
bundles.Add(new StyleBundle("~/bundles/publiccss").Include(
"~/Static/Css/bootstrap/bootstrap.css",
"~/Static/Css/bootstrap/bootstrap-padding-top.css",
"~/Static/Css/bootstrap/bootstrap-responsive.css",
"~/Static/Css/bootstrap/docs.css"));
bundles.Add(new ScriptBundle("~/bundles/publicjs").Include(
"~/Static/Js/jquery-1.7.2.js",
"~/Static/Js/bootstrap/bootstrap.js",
"~/Static/Js/cookie/jquery.cookie.js"));
Run Code Online (Sandbox Code Playgroud)
我没有在按钮上看到任何图标,同样如此.我在这里做错了吗?有什么建议?
asp.net asp.net-mvc-4 twitter-bootstrap bundling-and-minification asp.net-optimization
我正在尝试新的ASP.NET MVC 4移动功能.我用一个控制器(HomeController)和一个视图(索引)创建了一个简单的应用程序.我还添加了索引视图的移动版本.
Views/Home/Index.cshtml
Views/Home/Index.Mobile.cshtml
Run Code Online (Sandbox Code Playgroud)
在桌面浏览器中启动应用程序时,常规视图按预期显示,但是当我在Opera Mobile Emulator中作为Samsung Galaxy S 启动应用程序时,我仍然可以获得常规视图而不是移动版本.
从模拟器发送的用户代理字符串如下所示:
Opera/9.80 (Windows NT 6.1; Opera Mobi/23731; U; en) Presto/2.9.201 Version/11.50
Run Code Online (Sandbox Code Playgroud)
关于为什么这不起作用的任何想法?
更新 感谢@nemesv我能够解决问题,这是我目前的解决方案,希望它将涵盖大多数移动方案.
public class MobileDisplayMode : DefaultDisplayMode
{
private readonly StringCollection _useragenStringPartialIdentifiers = new StringCollection
{
"Android",
"Mobile",
"Opera Mobi",
"Samsung",
"HTC",
"Nokia",
"Ericsson",
"SonyEricsson",
"iPhone"
};
public MobileDisplayMode() : base("Mobile")
{
ContextCondition = (context => IsMobile(context.GetOverriddenUserAgent()));
}
private bool IsMobile(string useragentString)
{
return _useragenStringPartialIdentifiers.Cast<string>()
.Any(val => useragentString.IndexOf(val, StringComparison.InvariantCultureIgnoreCase) >= 0);
}
}
Run Code Online (Sandbox Code Playgroud)
我是Global.asax
DisplayModeProvider.Instance.Modes.Insert(0, …
Run Code Online (Sandbox Code Playgroud) 我有这个旧的MVC5应用程序,它以最简单的形式使用表单身份验证.web.config中只存储一个帐户,没有角色等.
<authentication mode="Forms">
<forms loginUrl="~/Login/Index" timeout="30">
<credentials passwordFormat="Clear">
<user name="some-user" password="some-password" />
</credentials>
</forms>
</authentication>
Run Code Online (Sandbox Code Playgroud)
登录例程只是调用
FormsAuthentication.Authenticate(name, password);
Run Code Online (Sandbox Code Playgroud)
就是这样.在asp.net核心中是否有类似的(在简单性方面)?
我正在使用jQuery tablesorter插件,我有一个包含月份和年份名称的列
April, 1975
January, 2001
Run Code Online (Sandbox Code Playgroud)
我想将此列排序为日期列.据我了解,可以使用其他一些"隐藏"值对列进行排序,但我似乎无法找到该功能的文档.有帮助吗?
更新
这个forkorter的叉子http://mottie.github.com/tablesorter/docs/index.html就是我所需要的; 能够存储值以在属性中排序,工作真的很棒.
我正在使用Visual Studio 2012和发布功能.我创建了一个发布配置文件,将我的应用程序部署到开发服务器,并且在我的机器上从vs2012执行时效果很好.这是我的问题; 在开发服务器上我也安装了TeamCity,我想在构建完成后触发发布.所以我创建了一个简单的构建步骤,如下所示:
Build file path: .\src\Solution.sln
Targets: Rebuild
Command line parameters: /p:DeployOnBuild=true;PublishProfile=Ci
Run Code Online (Sandbox Code Playgroud)
执行此步骤时,我收到以下错误:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web\Microsoft.Web.Publishing.targets(4377, 5): error ERROR_USER_NOT_ADMIN: Web deployment task failed.
(Connected to 'dev.domain.com' using the Web Deployment Agent Service, but could not authorize. Make sure you are an administrator on 'dev.domain.com'.
Run Code Online (Sandbox Code Playgroud)
Ci配置文件包含用户名和密码,当我在我的计算机上从Visual Studio运行发布时,该用户名和密码有效.我也尝试在构建步骤中传递用户名和密码作为参数,但我得到了相同的结果.我是否需要在管理员帐户下运行TeamCity服务才能使其正常运行?所有建议表示赞赏.
我一直在尝试ASP.NET MVC 4中新的缩小和捆绑功能,只要你使用css和js文件的默认文件夹约定,它就会很好用.
/Content
/Scripts
Run Code Online (Sandbox Code Playgroud)
我通常把css和脚本放在一个名为Static的文件夹中
/Static/Css
/Static/Js
Run Code Online (Sandbox Code Playgroud)
我试着像这样注册我自己的包:
public static class BundleCollectionExtensions
{
public static void RegisterScriptsAndCss(this BundleCollection bundles)
{
var bootstrapCss = new Bundle("~/Static/Css", new CssMinify());
bootstrapCss.AddDirectory("~/Static/Css", "*.css");
bootstrapCss.AddFile("~/Static/Css/MvcValidation.css");
bootstrapCss.AddFile("~/Static/Css/bootstrap-responsive.min.css");
bootstrapCss.AddFile("~/Static/Css/bootstrap.min.css");
bundles.Add(bootstrapCss);
var bootstrapJs = new Bundle("~/Static/Js", new JsMinify());
bootstrapJs.AddDirectory("~/Static/Js", "*.js");
bootstrapJs.AddFile("~/Static/Js/jquery-1.7.1.min.js");
bootstrapJs.AddFile("~/Static/Js/jquery.validate.min.js");
bootstrapJs.AddFile("~/Static/Js/jquery.validate.unobtrusive.min.js");
bootstrapJs.AddFile("~/Static/Js/bootstrap.min.js");
bootstrapJs.AddFile("~/Static/Js/gunsforhire.js");
bundles.Add(bootstrapJs);
}
}
Run Code Online (Sandbox Code Playgroud)
并在
Global.ascx.cs
Run Code Online (Sandbox Code Playgroud)
我这样做了:
BundleTable.Bundles.RegisterScriptsAndCss();
Run Code Online (Sandbox Code Playgroud)
生成的标记如下所示:
<link href="/Static/Css?v=D9JdmLZFFwjRwraNKfA1uei_YMoBoqLf-gFc0zHivM41" rel="stylesheet" type="text/css" />
<script src="/Static/Js?v=mbKbf5__802kj-2LS5j9Ba-wvSxBCKNMQGBgzou6iZs1" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
但是这不起作用,请求看起来像这样:
Request URL:http://localhost:49603/Static/Js?v=mbKbf5__802kj-2LS5j9Ba-wvSxBCKNMQGBgzou6iZs1
Request Method:GET
Status Code:301 Moved Permanently (from cache)
Query String Parametersview URL encoded …
Run Code Online (Sandbox Code Playgroud) 我与运行在Windows Server 2012上的SQL Server 2012实例有连接问题.我在运行Windows 7的客户端计算机上安装了.NET 4.5 Windows窗体应用程序.我得到的错误是这样的:
A connection was successfully established with the server, but then an error
occurred during the pre-login handshake. (provider: SSL Provider, error: 0 -
The wait operation timed out.)
Run Code Online (Sandbox Code Playgroud)
我的连接字符串如下所示:
server=SERVERNAME;database=DATABASENAME;User Id=someuser;password=somepassword;Timeout=60;app=LabelMaker
Run Code Online (Sandbox Code Playgroud)
我尝试使用QueryExpress从客户端计算机连接到SQL Server,这很有用 !如果有任何帮助,我的应用程序是64位.我已经检查了SQL Server中我能想到的每个设置.协议(共享内存和tcp/ip)上未启用强制加密,域防火墙在服务器上打开.我已经尝试了各种连接字符串和各种闻所未闻的关闭参数,总是相同的结果,失败.
我真的很困惑为什么它适用于QueryExpress?我的应用程序在另一台计算机上连接到SQL SERVER Express的远程实例时工作,如果我在SQL Server 2012计算机上运行它也可以.
我也尝试使用LinqPad从客户端机器连接到服务器,这也很奇怪,基于net4/4.5(版本:4.43.06)的新版本失败但是当我使用旧版本的Linqpad时( 2.x)基于net3.5它的工作原理!
看起来像熊猫安全导致了这个问题,我跑了
netsh winsock show catalog
Run Code Online (Sandbox Code Playgroud)
并找到了一些熊猫条目,然后我做了重置
netsh winsock reset
Run Code Online (Sandbox Code Playgroud)
现在我的应用程序工作正常,然后我重新启动机器,再次运行目录命令,熊猫条目又回来了,我的应用程序遇到了和以前一样的问题.
以下是winsock目录中的熊猫条目:https://gist.github.com/pellehenriksson/5159883
所有的想法和建议都表示赞赏.
UPDATE
熊猫安全v5是造成这个问题的原因,这已得到熊猫支持的证实.下面的Alex解释了问题的根本原因.客户将升级到熊猫安全的v6,我将在升级后再次测试.
结论 转向Panda Security v6.0解决了这个问题.
这是我的问题:每次我从内核请求一个实例时,我想将其中一个值传递给构造函数.我在下面写了一些代码来说明问题.测试没有失败,所以我猜这有效,但看起来确实很难看.使用Ninject有更好,更清洁的方法吗?或者我应该重新考虑我的设计?所有建议表示赞赏.
[TestFixture]
public class Sandbox
{
[Test]
public void Run_Forrest_Run()
{
using (var kernel = new StandardKernel(new Module()))
{
var connection = new Connection(Guid.NewGuid().ToString());
var downloader = kernel.Get<IDownloader>(new IParameter[] { new Parameter("connection", connection, false) });
Assert.That(downloader.Connection.Info, Is.EqualTo(connection.Info));
}
}
public class Downloader : IDownloader
{
public Downloader(Connection connection, ILogger logger)
{
Connection = connection;
Logger = logger;
}
public Connection Connection { get; private set; }
public void Download()
{
Logger.Log("Downloading...");
}
public ILogger Logger { get; private set; } …
Run Code Online (Sandbox Code Playgroud) 我正在尝试jqPlot,但我无法弄清楚如何设置不同系列的名称.
目前,我的代码如下所示:
$(document).ready(function () {
$.jqplot('chartdiv', [
[[201201, 10], [201202, 20], [201203, 30], [201204, 60], [201205, 40]],
[[201201, 5], [201202, 10], [201203, 7], [201204, 8], [201205, 11]]
], {
axes: {
xaxis: {
label: "Year/month",
pad: 0
},
yaxis: {
label: "Amount (Kr)"
}
},
legend: {
show: true
}
});
});
Run Code Online (Sandbox Code Playgroud)
它呈现图表,但系列被命名为系列1和系列2.有没有什么方法可以控制系列的命名?
我有一个非常简单的构建脚本,如下所示:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0" DefaultTargets="Bundle">
<ItemGroup>
<BuildArtifacts Include="..\_buildartifacts" />
<Application Include="..\_application" />
</ItemGroup>
<Target Name="Clean">
<RemoveDir Directories="@(BuildArtifacts)" />
<RemoveDir Directories="@(Application)" />
</Target>
<Target Name="Init" DependsOnTargets="Clean">
<MakeDir Directories="@(BuildArtifacts)" />
<MakeDir Directories="@(Application)" />
</Target>
<Target Name="Bundle" DependsOnTargets="Compile">
<Exec Command="xcopy.exe %(BuildArtifacts.FullPath) %(Application.FullPath) /e /EXCLUDE:$(MSBuildProjectDirectory)\files_to_ignore_when_bundling.txt" WorkingDirectory="C:\Windows\" />
</Target>
Run Code Online (Sandbox Code Playgroud)
问题是 Bundle 目标,只有%(BuildArtifacts.FullPath)
提取的内容%(BuildArtifacts.FullPath)
在脚本执行时被忽略。
执行时命令如下所示:
xcopy.exe C:\@Code\blaj_buildartifacts /e /EXCLUDE:C:\@Code\blaj\files_to_ignore_when_bundling.txt" exited with code 4
如您所见,目标路径不存在,如果我对路径进行硬编码或仅对目标路径进行硬编码,则一切正常。关于我在这里做错了什么有什么建议吗?
更新
我设法解决了问题,我删除了最后一部分WorkingDirectory="C:\Windows\"
并将脚本更改为:
<Exec Command="xcopy.exe @(BuildArtifacts) @(Application) /e /EXCLUDE:$(MSBuildProjectDirectory)\files_to_ignore_when_bundling.txt" />
Run Code Online (Sandbox Code Playgroud)
现在它可以工作了:)
我有一个xsd文件,如下所示:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Configurations">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Schema">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Table">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="Key">
<xs:complexType>
<xs:sequence>
<xs:element name="Column" maxOccurs="unbounded">
<xs:complexType>
<xs:attribute name="Name" type="xs:string" use="required" />
<xs:attribute name="Value" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Name" type="xs:string" use="required" />
<xs:attribute name="Value" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Name" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="Name" type="xs:string" use="required" />
<xs:attribute name="ConnectionString" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
Run Code Online (Sandbox Code Playgroud)
我只是无法弄清楚如何为元素xs:enumeration
的Name
属性创建一个 …
我在RegEx非常糟糕,在下面的代码中我只想要实际的数字SH:
和, or end of line.
我如何实现这一目标?
[TestMethod]
public void Sandbox()
{
var regEx = new Regex(@"SH\:(.*?)(\,|\z)");
var matches = regEx.Matches("Some Text|SH:0000000000,SH:1111111111");
foreach (var match in matches)
{
Console.Out.WriteLine(match);
/* Getting this
SH:0000000000,
SH:1111111111
*/
/* Wanting this
0000000000
1111111111
*/
}
}
Run Code Online (Sandbox Code Playgroud) 这是我的问题,Condition
我想获得正在评估的当前属性的名称。我相信你可以在早期版本的 Automapper 中做到这一点。有什么建议?
[TestFixture]
public class SandBox
{
public class MySource
{
public string Name { get; set; }
public int Count { get; set; }
}
public class MyDestination
{
public string Name { get; set; }
public int Count { get; set; }
}
public class SourceProfile : Profile
{
public SourceProfile()
{
this.CreateMap<MySource, MyDestination>()
.ForAllMembers(x => x.Condition((source, destination, arg3, arg4, resolutionContext) =>
{
// this will run twice (once for every property)
// but how …
Run Code Online (Sandbox Code Playgroud) c# ×3
.net-4.5 ×1
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
automapper-5 ×1
c#-4.0 ×1
c#-5.0 ×1
javascript ×1
jqplot ×1
jquery ×1
msbuild ×1
msbuild-4.0 ×1
msbuild-wpp ×1
ninject-2 ×1
regex ×1
tablesorter ×1
teamcity-7.0 ×1
xcopy ×1
xml ×1
xsd ×1