小编Nir*_*man的帖子

如何在web.config转换过程中添加文件?

我有一个在Visual Studio 2012中开发的网站.web.config目前在其转换中包含以下文件: - web.Debug.config - web.Release.config

我最近在我的项目中添加了一个新的构建配置(命名为"Staging").如何创建"web.Staging.config"转换文件?

web-config visual-studio-2012

70
推荐指数
3
解决办法
5万
查看次数

根据其数据类型"clientcontracttype",该值无效

我收到一条错误消息:

合同属性无效.根据其数据类型'clientcontracttype',该值无效

以下是此WCF应用程序的web.config中的端点配置.我正在使用.NET Framework 4.5和Visual Studio 2012.我已经验证合同OnlineReporting.Core.Contracts.IReportingInternalWcfPortal已经存在.

<endpoint address="http://localhost:63817/ReportingInternalWcfPortal.svc" 
          binding="basicHttpBinding" 
          bindingConfiguration="BasicHttpBinding" 
          contract="OnlineReporting.Core.Contracts.IReportingInternalWcfPortal" 
          name="ReportingInternalPortal" />
Run Code Online (Sandbox Code Playgroud)

wcf contract endpoint

25
推荐指数
3
解决办法
5万
查看次数

如何在@ Url.Action中传递动态值?

我在部分视图中写了以下jquery:

    $.ajax({
        type: "POST",
        url: '@Url.Action("PostActionName", "ControllerName")',
        data: { Id: "01" },
        success: function(data)
            {
            if (data.success="true")
                {
                    window.location = '@Url.Action("GetActionName", "ControllerName")'
                }
            }
    });
Run Code Online (Sandbox Code Playgroud)

动作名称和控制器名称不固定,它们必然会根据放置此局部视图的视图而改变.我有获取调用操作和控制器名称的函数,但不知道如何在@ Url.Action中传递它们.

以下是用于获取操作和控制器名称的Javascript函数:

function ControllerName() {
            var pathComponents = window.location.pathname.split('/');
            var controllerName;
            if (pathComponents.length >= 2) {
                if (pathComponents[0] != '') {
                    controllerName = pathComponents[0];
                }
                else {
                    controllerName = pathComponents[1];
                }
            }
            return controllerName;
        }

        function ActionName() {
            var pathComponents = window.location.pathname.split('/');
            var actionName;
            if (pathComponents.length >= 2) {
                if (pathComponents[0] != '') { …
Run Code Online (Sandbox Code Playgroud)

jquery url.action asp.net-mvc-4

17
推荐指数
1
解决办法
8万
查看次数

在IIS上部署站点时,CKEditor不工作

我在我的MVC应用程序中使用CKEditor.

我正在使用"ckeditor-full"(版本4.4.2)包.

我在包中包含了"ckeditor\adapters\jquery.js"和"ckeditor\ckeditor.js"文件,并在_Layout.cshtml文件中引用了这些包.

@Scripts.Render("~/bundles/Scripts/ckeditor")
@Scripts.Render("~/bundles/Scripts/ckeditor/adapters")
Run Code Online (Sandbox Code Playgroud)

"Scripts/ckeditor"文件夹包含随包一起下载的所有352个文件.

以下是config.js文件(它位于"Scripts/ckeditor"文件夹中.

CKEDITOR.editorConfig = function( config )
{
    // Define changes to default configuration here. For example:
    config.toolbar = 'Custom';
    config.disableNativeSpellChecker = false;
    config.browserContextMenuOnCtrl = true;
    config.forcePasteAsPlainText = true;

    config.toolbar_Custom = [
        { name: 'basicstyles', items: ['Bold', 'Italic', 'Underline', 'Strike', '-', 'RemoveFormat'] },
        { name: 'paste', items: ['PasteText'] },
        { name: 'links', items: ['Link', 'Unlink'] }
    ];
};
Run Code Online (Sandbox Code Playgroud)

以下是我如何显示textarea的CKEditor:

$("#idBodyText").ckeditor();
Run Code Online (Sandbox Code Playgroud)

问题是,它在本地工作正常,如果在调试模式下在本地IIS上运行.但是,在具有发布配置的IIS上部署时,它不会显示CKEditor.

知道可能的原因是什么,以及如何解决这个问题?

任何帮助都非常感谢.

谢谢

iis asp.net-mvc bundle ckeditor asp.net-mvc-4

15
推荐指数
1
解决办法
5435
查看次数

DIV中的两个DIV.如何通过第二个DIV自动填充父DIV的空间?

请访问这个小提琴,看看我的意思 -

我有一个父DIV,其中有两个DIV以垂直顺序放置.顶部DIV应仅具有其内容的高度,而底部DIV应占据父DIV的所有剩余空间,而不考虑内容高度,并且也不应与父DIV重叠.

HTML:

<div class="outer">
    <div  class="inner-title">
        THIS IS MY TITLE
    </div>
    <div class="inner-content">
        CONTENT AREA
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

html,body
{
height: 100%;
}

.outer
{
    background-color:blue;
    height: 80%;
}

.inner-title
{
    background-color:red;
}

.inner-content
{
background-color:yellow;
    height: auto;
}
Run Code Online (Sandbox Code Playgroud)

简而言之,"内部内容"应该占据"外部"DIV的所有剩余空间,而不会重叠.

知道怎么做到这一点?

任何帮助都非常感谢.

html css height autofill

11
推荐指数
2
解决办法
2万
查看次数

在我的EF实现Generic存储库中找不到.Include()方法

我使用Generic存储库从上层包装DbContext和DbSet类.但是,在某些查询中,我需要使用".Include()"方法来包含导航属性.但我无法在存储库方法上找到这些方法来恢复IQueryable

喜欢,

this.repository.GetQuery<GeneralCalendarDates>()
Run Code Online (Sandbox Code Playgroud)

这没有include方法,虽然我可以在这里使用.ToList().

知道这里有什么不对吗?

entity-framework repository-pattern

8
推荐指数
1
解决办法
5031
查看次数

无法将Base类(数据协定)强制转换为派生类

[DataContract]
public class SearchCriteria
{
    [DataMember]
    public string CountryID { get; set; }    
}

[DataContract]
public class CitySearchCriteria: SearchCriteria
{
    [DataMember]
    public string CityID { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我在我的MVC控制器操作中创建了一个SearchCriteria实例,并尝试将其转换为CitySearchCriteria.

SearchCriteria searchCriteria = new SearchCriteria();
searchCriteria.CountryID = "1";
CitySearchCriteria citySearchCriteria = searchCriteria as CitySearchCriteria;
Run Code Online (Sandbox Code Playgroud)

上述语句后面的"citySearchCriteria"对象显示NULL值.我希望它显示属性,CountryID和CityID,其中CountryID已填充,CityID为空......但它将对象设置为NULL.

这可能是什么解决方案?DataContract有什么用呢?

评论建议,你不能将基数转换为派生:但实际上,我已经在我的视图中成功完成了这一点,它只是在控制器操作中不起作用:

CitySearchCriteria citySearchCriteria = (CitySearchCriteria)Model.SearchCriteria;
Run Code Online (Sandbox Code Playgroud)

这是成功转换的,为什么类似的东西不能在控制器动作中工作呢?

c# oop casting derived-class datacontract

8
推荐指数
2
解决办法
1万
查看次数

设置MaxLength会给出错误

以下是我的MVC模型中的一个属性.

[Display(Name = "Event ID")]
[MaxLength(8, ErrorMessage = "Event ID can be of maximum 8 characters long")]
[Required(ErrorMessage="Event ID must be entered")]
public Nullable<int> ID_EVENTO { get; set; }
Run Code Online (Sandbox Code Playgroud)

我已使用View绑定模型,当我尝试单击"提交"按钮时,它会给出以下运行时错误 -

无法将"System.Int32"类型的对象强制转换为"System.Array"类型

然而,如果我删除"MaxLength"属性,它就会开始工作.

这可能是什么问题?

asp.net-mvc maxlength data-annotations asp.net-mvc-4

7
推荐指数
1
解决办法
3811
查看次数

如何将程序集版本设置为Jenkins内部版本号?

我在Jenkins中使用"更改程序集版本"插件来更新我的ASP.NET MVC项目的所有AssemblyInfo.cs文件,以在构建过程中应用版本号.如果我将"汇编版本"值设置为硬编码值,则效果非常好.

但我的要求是不同的 - 我想在版本号中使用内部版本号.例如,"1.1.0.25",其中25是内部版本编号,由Jenkins自动生成.简而言之,版本应该像"1.1.0.<>"

我可以使用TFS环境变量在TFS构建过程中执行此操作,我是Jenkins的新手,并且不确定如何在Jenkins中实现此目的.以下是Jenkins的"Change Assembly Version"插件的屏幕截图,供您快速参考:

在此输入图像描述

提前致谢

environment-variables jenkins jenkins-plugins

6
推荐指数
3
解决办法
1万
查看次数

如何使 SqlConnection 默认使用“SET ARITHABORT ON”?

最近,我们发现性能不佳的页面之一是由于 SQL Server 实例和 SQL 客户端(即 ADO.NET)之间 ARITHABORT 选项设置的差异造成的。我们可以通过在 SQLConnection 打开后立即执行以下命令来解决此问题 -

SqlCommand comm = new SqlCommand("SET ARITHABORT ON", objSqlConn);
comm.ExecuteNonQuery();
Run Code Online (Sandbox Code Playgroud)

互联网上有很多文章说,当查询从应用程序执行需要很长时间,但在 SSMS 中执行速度很快时,那么很可能是索引不良、参数嗅探或 ARTHABORT 选项差异的问题。就我而言,这是第三个,我也可以通过检查查询执行计划来重新确认。

虽然问题已经解决,但我很好奇为什么我需要显式运行此命令以使查询性能与 SQL Server 同步。

另外,如果多年来这是众所周知的事情,那么 Microsoft 一定考虑过将此选项默认设置为 SqlConnection 的 ON。毕竟,SQL Server 和.NET 客户端都是他们自己的产品。

知道如何在使用 ADO.NET 执行查询时默认设置 SET ARITHABORT ON 吗?

.net c# sql-server performance ado.net

5
推荐指数
1
解决办法
1万
查看次数