我的网页中有以下脚本元素:
<script src="default.js" type="text/javascript"></script>
Run Code Online (Sandbox Code Playgroud)
使用JavaScript,我希望能够检索脚本文件的内容.我知道我可以使用ajax请求获取数据,但后来我从本地已有的服务器获取了一些东西.
所以我更喜欢做的是从DOM中检索内容(如果可能的话)或具有相同结果的内容.
干杯安东尼
UPDATE
我试图简化问题,也许是一个糟糕的想法,我认为这样会导致更少的问题.
我的实际情况如下,我实际上有
<script type="text/html" class="jq-ItemTemplate_Approval">
...
html template that is going to be consumed by jQuery and jTemplate
...
</script>
Run Code Online (Sandbox Code Playgroud)
现在这工作正常,但这意味着每次页面加载我必须发送模板作为主页的html的一部分.所以我的计划是做以下事情:
<script src="template.html" type="text/html"></script>
Run Code Online (Sandbox Code Playgroud)
这意味着浏览器会缓存template.html的内容,我不必每次都发送它.但要做到这一点,我需要能够从文件中获取内容.
同样在这种情况下,据我所知,通过ajax请求内容并不会对此有所帮助,因为它必须返回服务器才能获取内容.
我已经为我的新asp.net mvc项目创建了以下项目结构,我得到了一些反馈,因为其他人正在构建他们的项目以及我是否会改进我的...
这是我到目前为止:
+Assets
-+Images
-+Scripts
-+Stylesheets
-+... 'More things like the above here
+Controllers
-+Support
--+Actions 'Any custom action classes
--+Controllers 'Base controller classes
+Models
-+Domain 'Contains any class that specialise view specific domain logic
--+UrlProcessing 'Encoding/decoding business entities as URL parts
--+... 'More things like the above here
-+Views 'Contains view models
--+Support
---+Views 'Base classes for any view models
+Support
-+Application 'Global application interface classes (i.e. class that wraps the function of the global asax)
-+Configuration 'Typed …Run Code Online (Sandbox Code Playgroud) 我需要能够将动态HTML(通过javascript在页面加载时呈现的html)转换为PDF.我知道有很多HTML到PDF转换器,但到目前为止我找到的没有一个处理动态HTML.
给定的工具应该能够成功转换以下页面 - http://www.simile-widgets.org/timeline/
干杯安东尼
更新:
我不需要这里的JavaScript功能...即我不需要能够与屏幕交互...我只是希望在PDF中捕获屏幕的最终渲染 - 就像在页面后拍照已加载.在我提供的示例中,javascript只是将div渲染到屏幕上,因此只要它"先让""页面"渲染它就不应该处理它.
我有一个使用集成安全性的ASP.Net MVC应用程序,我需要能够授予对特定路由的开放访问权限.有问题的路线是~/Agreements/Upload.我尝试了一些事情,迄今为止没有任何工作.
<configuration>
<location path="~/Agreements/Upload">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
在目录安全性>身份验证方法下的IIS中,我只选择了"集成Windows身份验证".现在,这可能是我的问题的一部分(尽管IIS允许上面的IIS没有).但是,如果是这种情况,我该如何配置它以便集成安全性工作但允许未经过身份验证的人访问给定路由?
.net asp.net-mvc authorization web-config integrated-security
只是想知道是否有人知道是否有任何MSBuild入门套件.
我对初学者工具包的意思是,从它的外观大多数构建到有点相同的步骤,在这里和那里进行微小的改变(即大多数构建将运行测试,覆盖,压缩结果,生成报告,部署等) .大多数人一般都希望从CI构建,测试构建,发布构建大致相同,只是在这里和那里进行微小的更改.
现在不要误解我的意思,我认为大多数脚本最终都是完全不同的.但我不禁想到,大多数人的生活都相当相似.
因此,有没有人知道任何"初学者工具包"有一个dev/CI /测试/发布版本与大多数人想要的常见任务,你可以开始改变和修改?
干杯安东尼
我有以下内容:
[ServiceContract]
[ServiceKnownType(typeof(ActionParameters))]
[ServiceKnownType(typeof(SportProgram))]
[ServiceKnownType(typeof(ActionResult<SportProgram>))]
public interface ISportProgramBl
{
[OperationContract]
IActionResult<ISportProgram> Get(IActionParameters parameters);
}
Run Code Online (Sandbox Code Playgroud)
当我运行Get方法时,我收到以下错误:
尝试序列化参数http://tempuri.org/:GetResult时出错.设置InnerException消息是'类型' PPS.Core.DomainModel.Support.Action.ActionResult`1 [[PPS.Core.DomainModel.SportProgram.ISportProgram,PPS.Core.DomainModel,版本= 1.0.0.0,文化=中性公钥=空]"数据合同名称'ActionResultOfanyType:http://schemas.datacontract.org/2004/07/PPS.Core.DomainModel.Support.Action ’预计不会.将任何静态未知的类型添加到已知类型列表中 - 例如,通过使用KnownTypeAttribute属性或将它们添加到传递给DataContractSerializer的已知类型列表中.有关更多详细信息,请参阅InnerException.
从这个错误我可以看到它可以解决ActionResult但它无法解析ISportProgram,即使我的服务接口上有ServiceKnownType(typeof(ActionResult <SportProgram>)) ...
请注意,这是生成的Reference存根看起来像这样,所以我可以看到已正确引入已知类型:
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(ConfigurationName="SportProgramStb.ISportProgramBl")]
public interface ISportProgramBl {
[System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/ISportProgramBl/Get", ReplyAction="http://tempuri.org/ISportProgramBl/GetResponse")]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(PPS.Core.DomainModel.SportProgram.SportProgram))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(PPS.Core.DomainModel.Support.Action.ActionParameters))]
[System.ServiceModel.ServiceKnownTypeAttribute(typeof(PPS.Core.DomainModel.Support.Action.ActionResult<PPS.Core.DomainModel.SportProgram.SportProgram>))]
object Get(object parameters);
}
Run Code Online (Sandbox Code Playgroud)
为什么会出错???? 请注意它正确地通过WCF服务...但它会在返回结果时抛出异常.
最后ActionResult看起来像这样:
public interface IActionResult<T>
{
T Result { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
干杯安东尼
我正在寻找第一次使用ELMAH,但是需要满足我不确定如何实现的要求......
基本上,我将配置ELMAH在asp.net MVC下工作,并让它在发生错误时将错误记录到数据库中.除此之外,我将使用customErrors在发生错误时将用户定向到友好的消息页面.相当标准的东西......
要求是在这个自定义错误页面上我有一个表单,使用户可以根据需要提供额外的信息.现在问题出现的原因是此时已经记录了错误,我需要将漏洞错误与用户反馈相关联.
通常,如果我使用自己的自定义实现,在记录错误后,我会将错误的ID传递给自定义错误页面,以便可以建立关联.但由于ELMAH的工作方式,我不认为这是可能的.
因此我想知道人们怎么会想到这样做......
干杯
更新:
我对这个问题的解决方案如下:
public class UserCurrentConextUsingWebContext : IUserCurrentConext
{
private const string _StoredExceptionName = "System.StoredException.";
private const string _StoredExceptionIdName = "System.StoredExceptionId.";
public virtual string UniqueAddress
{
get { return HttpContext.Current.Request.UserHostAddress; }
}
public Exception StoredException
{
get { return HttpContext.Current.Application[_StoredExceptionName + this.UniqueAddress] as Exception; }
set { HttpContext.Current.Application[_StoredExceptionName + this.UniqueAddress] = value; }
}
public string StoredExceptionId
{
get { return HttpContext.Current.Application[_StoredExceptionIdName + this.UniqueAddress] as string; }
set { HttpContext.Current.Application[_StoredExceptionIdName + this.UniqueAddress] = value; …Run Code Online (Sandbox Code Playgroud) 在n层应用程序的上下文中,您认为数据访问类与存储库之间存在差异吗?
我倾向于认为是,但我只是想看看其他人的想法.我的想法是存储库的工作只是包含和执行原始查询本身,其中数据访问类将创建上下文,执行存储库(传递上下文),处理将数据模型映射到域模型并将结果返回...
你们有什么感想?您是否也看到Linq to XML场景中的任何变化(假设您更改了相关XDocument的上下文)?
干杯安东尼
更新:
这是我以前通常实现的方式:
public class TermBl : ITermBl
{
public IEnumerable<ITerm> GetAll(IListParameter criteria)
{
//Any pre business logic
var dataLayer = this.CreateDataLayer();
var result = dataLayer.GetAll(criteria);
//Any post business logic
return result;
}
... Other methods
}
public class TermDa : ITermDa
{
public IEnumerable<ITerm> GetAll(IListParameter criteria)
{
//Linq query
var dataResult = ....ToList()
var mappedResult = this.FromDataToDomain(dataResult);
//Note the mapping isn't done in this object, the actual
// mapping is handled by a separate …Run Code Online (Sandbox Code Playgroud) 我知道以下是阻塞调用,并将返回可观察序列中的第一个值:
var result = myObservable.First();
Run Code Online (Sandbox Code Playgroud)
根据我使用的主题类型,这有不同的含义:
现在我试图找到一种获取最后一个值的一致方法,无论使用哪个底层Observable.
有任何想法吗?
我想创建一个单一的即DLL 合并与第三方DLL.这意味着最终消费者只需要处理1个dll而不是2个.
为了增加,可以说第三方dll是nLog.如何处理合并后的dll的消费者已经将NLog作为项目参考的情况?
理想情况下,我希望能够做的是将项目中的NLog名称空间更改为"XyzNLog",这意味着用户不需要进行任何别名...任何想法我怎么做?
现在我知道我可以为我的NLog项目添加别名,所以我必须将其称为XyzNLog,但我希望将其转移给合并dll的消费者,以便永远不会发生冲突.
更新 - 解决方案
http://blog.mattbrailsford.com/2010/12/10/avoiding-dependency-conflicts-using-ilmerge/
答对了!因此,通过使用ILMerge,可以将第三方库DLL与Providers自己的DLL合并,这意味着我们将只部署一个DLL.但这不是全部,我们实际上可以更进一步,并告诉ILMerge 内化所有依赖项.这样做会将所有第三方类转换为内部,这意味着它们只能在最终的DLL中使用.呜啊!问题解决=)
鉴于此问题,我的dll的消费者也可能有NLog消失...因为我引用的NLog转移到全部内部!这正是我想要的.
有没有人对此有任何反馈或想法?
.net ×5
asp.net-mvc ×3
c# ×2
html ×2
asp.net ×1
dhtml ×1
dll ×1
dom ×1
elmah ×1
generics ×1
ilmerge ×1
interface ×1
javascript ×1
linq ×1
linq-to-sql ×1
linq-to-xml ×1
msbuild ×1
msbuild-task ×1
package ×1
parsing ×1
pdf ×1
sample ×1
scripting ×1
solution ×1
wcf ×1
web-config ×1