在Windows Azure(预览)管理门户中,您可以更改网站的配置选项(请参阅http://www.windowsazure.com/en-us/manage/services/web-sites/how-to-configure-websites/ #howtochangeconfig).
我目前通过Web.Release.Config为我的ADO.NET实体框架连接设置连接字符串,但我想通过管理门户设置它,但无论我使用什么,我总是最终得到以下错误:
指定的命名连接在配置中找不到,不打算与EntityClient提供程序一起使用,或者无效.
它适用于常规连接字符串,即没有定义元数据和映射信息的元数据键(csdl,ssdl,msl).
这是我做的:
在"连接字符串"下,我有一个名为"ApplicationServices"的键,如下所示:
Server = tcp:xxxxx.database.windows.net,1433; Database = xxxxx; User ID = xxxxx @ xxxxx; Password = xxxxx; Trusted_Connection = False; Encrypt = True; Connection Timeout = 30;
这个工作.
我有另一个用于Entity Framework连接的密钥.我们称之为一个FooBarContext.它看起来像这样:
metadata = res:// /Models.FooBarContext.csdl|res:// /Models.FooBarContext.ssdl|res://*/Models.FooBarContext.msl;provider=System.Data.SqlClient;provider connection string ="Server = tcp:fooserver.database.windows.net,1433; Database = foobar; User ID = myname @ fooserver; Password = xxxxxxxxxx; Trusted_Connection = False; Encrypt = True; Connection Timeout = 30;"
这个导致上述错误.它是从Web.Release.Config中的工作值复制的,带有" 取而代之的是".
我尝试了其他变体:" 未触及,最后添加了元数据,但无济于事.我已经通过第二个网站重现了这个问题.
deployment entity-framework connection-string azure azure-web-sites
我的模型包含一个名为的属性Title,在我Create看来,我使用了设置页面标题ViewBag.Title.
这会产生以下问题:生成的表单Html.Editor将显示文本ViewBag.Title,而不是模型的Title值.
我找到的唯一解决方法是先调用Html.Editor,然后设置View.Title.
有没有人有更好的解决方案?
编辑1:我正在使用MVC 3.
编辑2:这是我的DisplayTemplates/Object.cshtml:
@model dynamic
@using Iconum.VS10CS040.Library.Web.MVC3.Helpers
@if (ViewData.TemplateInfo.TemplateDepth > 1) {
<span class="editor-object simple">@ViewData.ModelMetadata.SimpleDisplayText</span>
} else {
foreach (var prop in ViewData.ModelMetadata.Properties.Where(
pm =>
pm.ShowForEdit
&& !ViewData.TemplateInfo.Visited(pm)
&& pm.ModelType != typeof(System.Data.EntityState)
&& !pm.IsComplexType
)
)
{
if (prop.HideSurroundingHtml) {
<text>@Html.Editor(prop.PropertyName)</text>
} else {
string css = "";
if (prop.Model != null && prop.Model.GetType() != null)
{
css …Run Code Online (Sandbox Code Playgroud) 我想用这些URL到达Bikes控制器:
/bikes // (default path for US)
/ca/bikes // (path for Canada)
Run Code Online (Sandbox Code Playgroud)
实现这一目标的一种方法是每个Action使用多个Route Attributes:
[Route("bikes")]
[Route("{country}/bikes")]
public ActionResult Index()
Run Code Online (Sandbox Code Playgroud)
为了保持DRY,我更喜欢使用RoutePrefix,但不允许使用多个Route Prefix:
[RoutePrefix("bikes")]
[RoutePrefix("{country}/bikes")] // <-- Error: Duplicate 'RoutePrefix' attribute
public class BikesController : BaseController
[Route("")]
public ActionResult Index()
Run Code Online (Sandbox Code Playgroud)
我试过使用这个Route Prefix:
[RoutePrefix("{country}/bikes")]
public class BikesController : BaseController
Run Code Online (Sandbox Code Playgroud)
结果:/ ca / bikes工作,/自行车404s.
我试过让国家选择:
[RoutePrefix("{country?}/bikes")]
public class BikesController : BaseController
Run Code Online (Sandbox Code Playgroud)
相同的结果:/ ca / bikes工作,/自行车404s.
我试过给国家一个默认值:
[RoutePrefix("{country=us}/bikes")]
public class BikesController : BaseController
Run Code Online (Sandbox Code Playgroud)
相同的结果:/ ca / bikes工作,/自行车404s.
有没有其他方法可以使用属性路由实现我的目标? (是的,我知道我可以通过在RouteConfig.cs中注册路由来完成这些工作,但这不是我在这里寻找的东西).
我正在使用Microsoft.AspNet.Mvc 5.2.2.
仅供参考:这些是简化示例 - 实际代码具有{country}值的IRouteConstraint,例如:
[Route("{country:countrycode}/bikes")]
Run Code Online (Sandbox Code Playgroud) 我想从所有项目的单个Visual Studio(在线)工作空间转变为为每个项目提供单独的工作空间(因为:http://blogs.msdn.com/b/phkelley/archive/2013/05/30 /using-multiple-workspaces-with-visual-studio.aspx).
这一切都很好,但现在我想向同事们推出这种新方法,并且遇到了一个问题,看起来没有简单的方法与他们共享Workspace设置.
以下是VS 2013的MSDN文章中的官方建议,标题为"创建和使用工作区":
问:我可以重用和共享文件夹映射吗?
答:是的.如果要重新使用或与其他团队成员共享文件夹映射,则可以复制文件夹映射.只需打开工作文件夹列表中的快捷菜单,然后选择复制.要重用文件夹映射,请将它们粘贴到另一个版本控制工作区或构建定义工作区.要与您的队友共享文件夹映射,请将它们粘贴到文本文件中,然后共享该文件.
来源:http://msdn.microsoft.com/en-us/library/ms181383.aspx#copy_paste
我认为答案应该是"否.无法导出和导入Workspace文件夹映射"."将它们粘贴到文本文件并共享文件"的建议简直就是热闹.
我的研究发现,对于Team Foundation Server的服务器版本,有一个叫做工作区模板的东西:
使用工作区模板,您可以为开发人员提供组织工作区的标准方法.您的整个团队使用相同的结构并享受所有好处.
据我所知,这在Visual Studio Online(Team Foundation Server的云版本)中不可用.
所以我的问题是:有没有办法轻松共享Visual Studio Online/Team Foundation Server的Workspace设置(文件夹映射)?如果没有,是否有人知道比复制/粘贴/分享建议更好的方法?