我有AngularJS种子项目,我已经添加了
$locationProvider.html5Mode(true).hashPrefix('!');
Run Code Online (Sandbox Code Playgroud)
到app.js文件.我想配置IIS 7以将所有请求路由到
http://localhost/app/index.html
Run Code Online (Sandbox Code Playgroud)
这对我有用.我该怎么做呢?
更新:
我刚刚发现,下载并安装了IIS URL Rewrite模块,希望这样可以轻松,明显地实现我的目标.
更新2:
我想这总结了我想要实现的目标(取自AngularJS Developer文档):
使用此模式需要在服务器端重写URL,基本上您必须重写所有链接到应用程序的入口点(例如index.html)
更新3:
我还在努力,我意识到我不需要重定向(有重写规则)某些URL,例如
http://localhost/app/lib/angular/angular.js
http://localhost/app/partials/partial1.html
Run Code Online (Sandbox Code Playgroud)
所以css,js,lib或partials目录中的任何内容都不会被重定向.其他所有内容都需要重定向到app/index.html
任何人都知道如何轻松实现这一点,而无需为每个文件添加规则?
更新4:
我在IIS URL重写模块中定义了2个入站规则.第一条规则是:
第二条规则是:
现在,当我导航到localhost/app/view1时,它会加载页面,但是支持文件(css,js,lib和partials目录中的文件)也被重写到app/index.html页面 - 所以一切都将到来无论使用什么URL,都返回index.html页面.我想这意味着我的第一条规则,即应该阻止这些网址被第二条规则处理,不起作用..任何想法?...任何人?...我感觉很孤单... :-(
如何在列上放置约束以使其只包含以下值?你怎么称呼这种约束?
Allowed values: "yes", "no" or "maybe"
Column Data Type: nvarchar(5)
DBMS: SQL Server 2008
Run Code Online (Sandbox Code Playgroud) 我想做一个像这样的脚手架:
rails generate scaffold Job started_at:datetime completed_at:datetime price:decimal paid_at:datetime estimated_completion_at:datetime comment:text
Run Code Online (Sandbox Code Playgroud)
我在日期时间字段中添加了"_at",因为这似乎是惯例,因为rails时间戳字段对于datetime是"_at",对于date是"_on".但这实际上是一个惯例吗?如果我只是"付费"而不是"paid_at"和"completed"而不是"completed_at",这样可以吗?
我真的想从一开始就做到这一点.我已经用c#编程多年了,但我是ruby on rails的新手.我喜欢所有的约定,我想确保我正在做这个正确的'rails方式'.
coding-style ruby-on-rails naming-conventions ruby-on-rails-3
我正在关注新的Ubuntu 12.10上的ruby on rails入门指南.我要运行rake db:create
但是我收到以下错误:
耙子流产了!找不到JavaScript运行时.有关可用运行时的列表,请参阅https://github.com/sstephenson/execjs.
我一直在搜索,建议的解决方案(见下面列表)是安装一些therubyracer或nodejs,但他们没有解释原因.
在我安装之前我想知道这些JavaScript运行时之间的差异以及为什么我会选择其中一个?
更新:
我刚看了https://github.com/sstephenson/execjs(我知道我应该先读这个,对不起)在我看来,execjs不是一个JavaScript运行时而且我已经拥有它...所以它归结为therubyracer和nodejs ...请原谅我的无知,我已经修改了我的问题
除了Intrepidd的回答:
轨道上的红宝石入门指南支持Intrepidd的答案.请参见4.1"启动Web服务器"一节,其中说:
Rails在一个注释行中为新应用添加了therubyracer gem到Gemfile,如果需要,你可以取消注释.
对于那里的导轨noob(像我一样),GemFile位于rails应用程序的根文件夹中.在我的GemFile中取消注释该行后,我必须运行bundle install
以安装therubyracer gem.
这里有区别吗?
Button1.Click -= new EventHandler(Button1_Click);
Run Code Online (Sandbox Code Playgroud)
和
Button1.Click -= Button1_Click;
Run Code Online (Sandbox Code Playgroud)
第二种方法对我来说似乎不起作用,但我已经看到它在Google-ing'如何删除事件处理程序'时使用.编辑:实际上两个都不适合我,即使这样也应该互换?
更新:
这些似乎对我不起作用的原因是因为我的控件上有AutoPostBack = true.我没有设置断点来查看事件是否被调用,我只是看着浏览器看它是否刷新(意味着回发).
在我的客户详细信息组件中,我有以下代码可以实现我所追求的目标,但不是我认为可能的反应/可观察方式.
而不是包装this.isLoading = true;
在if语句中,有没有办法使用反应式编程技术?如果首先检索客户,可能通过取消/删除延迟的可观察量?或者,我是否采取了错误的方式?
export class CustomerDetailComponent implements OnInit {
customer: Customer;
errorMessage: string;
isLoading: boolean;
constructor(
private customerService: CustomerService,
private route: ActivatedRoute,
private router: Router,
private location: Location
) { }
ngOnInit() {
let idParam = this.route.params
.distinctUntilChanged(params => params['id']);
idParam.subscribe(params =>
{
this.errorMessage = '';
});
idParam.delay(300).subscribe(params =>
{
if (!(this.customer && this.customer.id == params['id']))
this.isLoading = true;
});
idParam.switchMap((params: Params) => this.customerService.getCustomer(params['id']))
.subscribe(customer =>
{
this.customer = customer;
this.isLoading = false;
},
error => this.errorMessage …
Run Code Online (Sandbox Code Playgroud) 我复制了一些代码来解决在ASP.Net中进行AJAX回发后运行JavaScript的问题.不幸的是,新代码在进行构建时给了我以下错误:
The name 'ScriptManager' does not exist in the current context
Run Code Online (Sandbox Code Playgroud)
现在我以前使用过ScriptManager,为什么现在会给我带来问题呢?是不是所有ASP.Net页面都可用?毕竟我的母版页上有一个脚本管理器......
我会尽量简单,如果您需要更多信息,请告诉我.我下载了ILMerge将Newtonsoft.Json.dll合并到我的类库中.我正在使用以下内容从post-build事件命令行调用ILMerge:
"$(ProjectDir)bin\ILMerge.exe" /internalize:"$(ProjectDir)bin\ILMergeIncludes.txt" /out:"$(TargetDir)$(TargetName).all.dll" "$(TargetDir)$(TargetName).dll" "$(TargetDir)*.dll" /target:library /targetplatform:v4,C:\Windows\Microsoft.NET\Framework64\v4.0.30319 /wildcards
Run Code Online (Sandbox Code Playgroud)
在输出窗口中,它显示:
An exception occurred during merging:
ILMerge.Merge: ERROR!!: Duplicate type 'myLibrary.some.class' found in assembly 'myLibrary.all'. Do you want to use the /alllowDup option?
at ILMerging.ILMerge.MergeInAssembly(AssemblyNode a, Boolean makeNonPublic, Boolean targetAssemblyIsComVisible)
at ILMerging.ILMerge.Merge()
at ILMerging.ILMerge.Main(String[] args)
Run Code Online (Sandbox Code Playgroud)
问题是'myLibrary.some.class'不是重复的.
我一直在互联网上寻找线索,所有我发现的是以下2个链接,以及一些网页应用程序,其中人们有复制/粘贴页面,忘了更改类名.
我尝试过使用allowDup选项,但在合并的dll中,它将'myLibrary.some.class'变成'myLibrary.some.random125624.class'.然后我尝试使用allowDup传递'class'然后我得到'class2'然后'class3'然后'class4'的"Duplicate type"错误......似乎没有结束重复类型的数量!
我确信这些类不是重复的,因为命名空间对我的公司和项目非常具体.
有人可以帮忙吗?
我们有一个现有的asp.net 4.0网站,它使用HttpRuntime.Cache做很多事情.它是在我开始处理之前创建的,现在我们遇到了缓存被清除和网站崩溃的问题,因为它总是希望缓存在那里(我知道......他们认为缓存是什么!?).
所以我需要的是一个永久性的替换缓存,所以我可以将它交换为HttpRuntime.Cache,而不会影响网站.我已经看过序列化,但并不是所有的对象都是可序列化的,并且它们不是一个可以将它们全部序列化的选项(有太多它们分散在各处).
有没有办法将任何内存对象/变量/任何内容保存到磁盘,并在以后读取它,而不必序列化它?
更新:
感谢您的评论和答案到目前为止.从你的想法开始,我做了一些谷歌搜索,并发现这篇文章演示了(如果你可以下载一个示例解决方案)如何在.Net 4.0中使用自己的自定义缓存提供程序.我还没有能够将它集成到我们的网络应用程序中并给它一个适当的测试(希望今天晚些时候我能够)但我想我会把它放在这里,看看你是否有任何想法. ..你觉得怎么样,我应该注意哪些警告?或者这是一个可行的(也是非常临时的)解决方案?
我正在寻找的是一种在离线Web应用程序中"上传"图像的方法.我希望有一种方法可以将所选图像存储在缓存中,然后在再次访问Internet时上传它.这样的事情可能吗?
我在ASP.Net MVC 4应用程序中使用了Kendo UI Web Grid.
在下面代码的底部,您将看到一个名为GetEditChildUrl的JavaScript函数,它接受一个名为data的参数.不幸的是,作为数据参数传入的内容是父行数据,但我期待子行数据.这适用于GetEditParentUrl.那么如何获取子行数据呢?
@(Html.Kendo().Grid<Application.Models.Parent>()
.Name("grid_parent")
.Columns(columns =>
{
columns.Bound(x => x.Name);
columns.Bound(x => x).ClientTemplate(
"<a href='#= GetEditParentUrl(data) #' class='k-button' style='min-width:0px;'><span class='k-icon k-i-pencil'></span></a>"
).Width(90).Filterable(false);
})
.Scrollable(action => action.Virtual(true))
.Filterable()
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Parents_Read", "Parent"))
)
.Scrollable(s => s.Height("auto"))
.ClientDetailTemplateId("client-template")
)
@section Scripts {
<script id="client-template" type="text/x-kendo-template">
<h3>Contacts</h3>
@(Html.Kendo().Grid<Application.Models.Child>()
.Name("grid_child_#=Id#") // make sure the Name is unique
.Columns(columns =>
{
columns.Bound(x => x.Name);
columns.Bound(x => x).ClientTemplate(
"<a href='#= GetEditChildUrl(data) #' class='k-button' style='min-width:0px;'><span class='k-icon k-i-pencil'></span></a>" …
Run Code Online (Sandbox Code Playgroud) 我只以调试模式发布以在本地计算机上进行测试,我希望可以使用“ #if debug”模式,以便可以测试生产中不需要的功能。
当我以调试模式发布时,web.config仍然具有
<system.web>
<compilation debug="true" targetFramework="4.0">
</system.web>
Run Code Online (Sandbox Code Playgroud)
但是当我在项目的dll上使用反射器时,代码是这样的
#if debug
PlaceHolder1.Visible = true;
#endif
Run Code Online (Sandbox Code Playgroud)
不存在。我认为编译器已将其删除。
注意:我不是在讨论构建,而是在发布。使用上面的代码,我可以像预期的那样进行调试构建
这是预期的行为吗?当我在调试模式下发布时,是否有办法让编译器包括那些代码?我要解决所有这些错误吗?
更新: 为响应@dash的评论,我的打包/发布Web设置为:
javascript ×4
asp.net ×3
c# ×3
.net ×2
.net-4.5 ×1
angular ×1
angularjs ×1
asp.net-ajax ×1
asp.net-mvc ×1
coding-style ×1
compilation ×1
constraints ×1
database ×1
file-upload ×1
html5 ×1
iis ×1
ilmerge ×1
kendo-grid ×1
kendo-ui ×1
offline ×1
rake ×1
ruby ×1
rxjs ×1
rxjs5 ×1
sql-server ×1
typescript ×1
webforms ×1