我们有一个使用WebForms .aspx文件的应用程序几乎所有东西.Latley我们一直在使用预编译的RazorViews,通过简单地在我们的项目中删除一个新的dll来获取nicley打包功能.但现在我们发现我们的预编译视图似乎与我们的VirtualPathProviders冲突.
从外部dll加载VirtualPathProviders时,应用程序尝试为所有请求加载PrecompiledApp.config(我们没有得到它).提供者加载了反射.我们在注册的同一个项目中有一些VirtualPathProviders,它们工作正常,但是当我们从外部dll注册提供程序时,HostingEnvironment.RegisterVirtualPathProvider我们遇到了这个问题.
如果我们添加文件PrecompiledApp.config,它会尝试获取_appstart.cshtml,依此类推.在通过这个例外之前我们必须拥有以下所有的所有文件:
我们最终在default.cshtml中,其余的应用程序工作.由于我们希望使用apsx文件作为默认值,因此这不是一个可接受的解决方案.我们也担心会出现更多问题,因为我们不知道为什么会这样.
我们尝试过这种加载我们的提供程序的方法,但我们仍然得到同样的错误:http: //sunali.com/2008/01/09/virtualpathprovider-in-precompiled-web-sites/
例外情况:
Could not find file 'C:\MyApp\PrecompiledApp.config'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.IO.FileNotFoundException: Could not find file 'C:\MyApp\PrecompiledApp.config'.
Source Error:
An unhandled exception was generated during the execution of the current web request. …Run Code Online (Sandbox Code Playgroud) 我们有一个名为Organization的实体,我们使用UniqueConstraints-bundle.我们有一个名为NetName的属性,它是一个UniqueConstraint和一个自动生成的Id.
由于这是不必要的,我们希望将NetName属性用作Id.因此,我们不需要UniqueConstraints来知道它是唯一的,并且当我们拥有NetName时能够使用Load也能获得好处.
在将它用作Id之前,我们需要稍微清理一下我们的网络名,因此我们创建了一个名为TempUniqueNetName的新临时属性,该属性现在保存的值为:
"organizations/"+ CleanupId(this.NetName)
Run Code Online (Sandbox Code Playgroud)
所以我们现在准备好将该值移动到我们的Id.但我们无法让它发挥作用.我们的问题是,在下面的PatchRequest中,我们最终得到了一个名为Id的新属性,但是acctual Id仍然具有相同的值(见截图).是否有更好(正确)的方法来更改Id的值?
实体:
class Organization {
public string Id { get; set; }
[UniqueConstraint]
public string NetName { get; set; }
public string TempUniqueNetName{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我们想做这样的事情:
_documentStore.DatabaseCommands.UpdateByIndex(typeof(Organizations).Name,
new IndexQuery(),
new[]
{
new PatchRequest()
{
Type = PatchCommandType.Rename,
Name = "TempUniqueNetName",
Value = new RavenJValue("Id")
}
});
Run Code Online (Sandbox Code Playgroud)
