我需要根据一组单词从字符串中删除单词:
我要删除的字词:
DE DA DAS DO DOS AN NAS NO NOS EM E A AS O OS AO AOS P LDA AND
Run Code Online (Sandbox Code Playgroud)
如果我收到如下字符串:
编辑:此字符串已从任何符号"清除"
THIS IS AN AMAZING WEBSITE AND LAYOUT
Run Code Online (Sandbox Code Playgroud)
结果应该是:
THIS IS AMAZING WEBSITE LAYOUT
Run Code Online (Sandbox Code Playgroud)
到目前为止,我有:
public static string StringWordsRemove(string stringToClean, string wordsToRemove)
{
string[] splitWords = wordsToRemove.Split(new Char[] { ' ' });
string pattern = "";
foreach (string word in splitWords)
{
pattern = @"\b" + word + "\b";
stringToClean = Regex.Replace(stringToClean, pattern, "");
}
return …Run Code Online (Sandbox Code Playgroud) 我想获得包括标签在内的帖子列表.
我有模特:
public class BlogPostGetByUrlSlugDto
{
public int Id { get; set; }
public string Title { get; set; }
public string Category { get; set; }
public string Color { get; set; }
public string UrlSlug { get; set; }
public string Description { get; set; }
public IList<BlogTagGetByPostIdDto> Tags { get; set; }
}
public class BlogTagGetByPostIdDto
{
public string Name { get; set; }
public string UrlSlug { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的代码到目前为止:
public BlogPostGetByUrlSlugDto …Run Code Online (Sandbox Code Playgroud) 我有两个MVC网站:
www.website1.com/Mobilewww.website2.com我需要创建一个指向www.website1.com/Mobile的URL www.website1.com/mobile,无需任何重定向,我必须留在URL www.website2.com/Mobile并打开www.website1的内容. com/Mobile Controller/View.
我有一个运行的MVC Web应用程序,www.domain.com我需要www.domain2.com为同一个Web应用程序的另一个域配置不同的URL绑定.
新域www.domain2.com必须返回特定的Controller Action View,如/Category/Cars:
routes.MapRoute(
name: "www.domain2.com",
url: "www.domain2.com",
defaults: new { controller = "Category", action = "Cars", id = UrlParameter.Optional }
);
Run Code Online (Sandbox Code Playgroud)
如何在不更改URL的情况下实现此目的,以便访问者插入URL www.domain2.com并接收视图,www.domain.com/category/cars但网址仍然存在www.domain2.com?
编辑:
我尝试过这种方法,但它不起作用:
routes.MapRoute(
"Catchdomain2",
"{www.domain2.com}",
new { controller = "Category", action = "Cars" }
);
Run Code Online (Sandbox Code Playgroud) 我正在尝试从我的 FTP 服务器下载文件,但从我的生产服务器(我可以从我的笔记本电脑下载该文件)收到错误“对 SSPI 的调用失败”和内部异常“收到的消息是意外的或格式错误”。这是我的代码:
var ftpServer = "ftp://xxx.yyy.zz/";
var ftpUsername = "aaaaa";
var ftpPassword = "bbbbb";
var downloadedFilePath = "c:\\temp\\";
var downloadedFileName = "file.xls";
FtpWebRequest request = null;
ServicePointManager.SecurityProtocol = ServicePointManager.SecurityProtocol | SecurityProtocolType.Tls12;
ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) {
return true;
};
// Get the object used to communicate with the server.
request = (FtpWebRequest)WebRequest.Create(ftpServer + "file_on_ftp_server.xls");
// download the file
request.Method = WebRequestMethods.Ftp.DownloadFile;
request.Credentials = new NetworkCredential(ftpUsername, ftpPassword);
request.EnableSsl = true;
request.KeepAlive …Run Code Online (Sandbox Code Playgroud) 我需要在带有布局的MVC项目中创建一个CSS命名约定.
在选择类的名称时,Layouts的使用需要非常小心,因为它可以被布局CSS文件中声明的一个覆盖.
我使用的一个规则是只使用样式的元素类和jQuery使用的元素ID.
假设我有这样的布局:
<div class="lyb-ctn">
<div class="lyb-wrp">
@RenderBody()
<div class="lyb-ctn-rgt">
<div class="lyb-ctn-subscribe">
<p class="lyb-ctn-subscribe-title">Subscribe</p>
<input placeholder="Email" /><input type="button" />
</div>
<div class="lyb-ctn-categories">
<p class="lyb-ctn-categories-title">Categories</p>
<div class="lyb-ctn-categories-ctn-list">
<div class="category">
<p>Cars</p>
<p>Boats</p>
</div>
</div>
</div>
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
一种选择是:
.lyb-ctn {
position:fixed;
padding:0px;
margin:0px;
width:100%;
height:100%;
background-color: #f2f2f2;
padding-top: 50px;
}
.lyb-wrp {
max-width: 960px;
width: 95%;
margin: auto;
background-color: #ffd800;
}
.lyb-ctn-rgt {
float: right;
width: 235px;
border: solid 1px #ff6a00;
}
.lyb-ctn-subscribe {
width: 100%;
}
.lyb-ctn-subscribe-title {
color: …Run Code Online (Sandbox Code Playgroud) 如果它比X字符更长,我如何格式化Razor CSHTML页面中的字符串:
<p>@Model.Council</p>
Example for an X = 9
-> if Council is "Lisbon", then the result is "<p>Lisbon</p>"
-> if Council is "Vila Real de Santo António", then the result is "<p>Vila Real...</p>" with the title over the <p> "Vila Real de Santo António" showing the complete information
Run Code Online (Sandbox Code Playgroud)
谢谢.
如何根据角色中的一组用户在视图中应用权限.
例如,如何为角色编辑器显示"创建文章"按钮并将其隐藏为角色Reader?
我正在构建一个项目,其中包含许多关于剃刀视图的常用代码.
例:
<div class="form-group">
@Html.LabelFor(model => model.LayoutFrontAmount, htmlAttributes: new { @class = "control-label col-xs-12 col-sm-4 col-md-3" })
<div class="col-xs-4 col-sm-2 col-md-2 col-lg-1">
@Html.EditorFor(model => model.LayoutFrontAmount, new { htmlAttributes = new { @class = "form-control" } })
</div>
<div class="col-xs-12 col-md-8 col-sm-offset-4 col-md-offset-3">
<span class="help-block">@Html.ValidationMessageFor(model => model.LayoutFrontAmount, "", new { @class = "text-danger" })</span>
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.LayoutFrontBackAmount, htmlAttributes: new { @class = "control-label col-xs-12 col-sm-4 col-md-3" })
<div class="col-xs-4 col-sm-2 col-md-2 col-lg-1">
@Html.EditorFor(model => model.LayoutFrontBackAmount, new { …Run Code Online (Sandbox Code Playgroud) 我有两个区别MVC Web应用程序访问:
1) product.main-brand.com (solution landing page)
2) admin.product.main-brand.com (solution admin landing page)
Run Code Online (Sandbox Code Playgroud)
该产品将改变位置:
product.main-brand.com to www.main-brand-com/product
Run Code Online (Sandbox Code Playgroud)
管理员必须改变:
admin.product.main-brand.com to www.main-brand-com/product/admin
Run Code Online (Sandbox Code Playgroud)
我无法为管理员创建虚拟目录,因为www.main-brand-com/product是一个控制器.
例如,NopCommerce这样做,我们可以从www.shop.com转到www.shop.com/admin,它正在改变项目,而不是控制器/行动.他是怎么做到的?
asp.net-mvc ×8
c# ×8
iis ×2
razor ×2
.net ×1
arrays ×1
css ×1
nopcommerce ×1
routes ×1
routing ×1
security ×1
ssl ×1
string ×1
url-routing ×1