如何在不使用第三方的情况下在asp.net中创建cms? [英] How to create cms in asp.net without using thirdparty?
问题描述
我需要创建cms类型的页面而不使用像umbraco,joomla,drupal等第三方。我只想使用asp.net C#编码......有任何例子......
I need to create cms type pages without using third parties like umbraco,joomla,drupal etc..only i wanted to use asp.net C# coding..there have any examples...
推荐答案
google上可能有一些例子,但显然没有足够的空间来解释这一切。我建议搜索一些示例文章或者刚刚开始,然后在有特定问题时再回来。
There are likely some examples on google but there is clearly not enough space here to explain it all to you. I would suggest searching for some example articles or just getting started on it and then come back when you have a specific question.
你好
cms对数据库驱动的应用程序没有任何影响
利用VS和c#的优点,并且很容易创建连接我将在启动时使用MVC
布局之前我将创建一个功能
例如通过创建模型将指定一些功能Banner Logo或者某些图形
for Logo我将使用类似
的东西
Hello
cms is nothing lase then database driven application
use advantage of VS and c# and that its easy to create that connections I will use MVC on start
before layout i will create a functionality
for example by creating Models what will specify some of the functionality Banner Logo or some graphic
for Logo i will use something like
public byte[] Logo { get; set; }
[HiddenInput(DisplayValue = true)]
public string logoMimeType { get; set; }
这是将它保存在数据库中的例子,但是你可以在文件夹中将它放到你的corse文件夹中对网站来说会更好
这将是你的型号
设置一个控制器
that's example for keeping it in database but u can do it in folder to up to u of corse folder will be better for websites
That will be ur model
the set up a controller
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Edit([Bind(Include = "MyLogoID,Logo,ImageMimeType")]
MyLogo mylogo, HttpPostedFileBase image)
{
if (ModelState.IsValid)
{
if (image != null) {
mylogo.logoMimeType = image.ContentType;
mylogo.Logo = new byte[image.ContentLength];
image.InputStream.Read(mylogo.Logo, 0, image.ContentLength);
}
db.Entry(mylogo).State = EntityState.Modified;
TempData["message"] = string.Format("{0} has beensaved", mylogo.Name);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(Logo);
}
现在创建一些可以从数据库或文件夹中提取徽标的内容/>
now create something what will pull the logo from database or folder
public FileContentResult GetImage(int mylogoId)
{ MyLogo emp = db.MyLogo.FirstOrDefault(p => p.MyLogoID == mylogoId);
if (emp != null) {
return File(emp.Logo, emp.logoMimeType);
} else {
return null;
}
}
现在我们需要得到的东西将把所有这些全部放到视图中放在网站上
and now we need to get something what will put that all to the view and in place on website
<img width="150" height="150" src="@Url.Action("GetImage", "Mylogo", new { Model.MyLogoID })" />
或你可以使用HTML帮助器
我可能会想念错过的东西xD
但是你只有一个功能你可以添加Logo现在到网上并将其存储在数据库中!
希望我不需要告诉你如何创建表单并查看它上传和使用控制器
or u can use HTML helper
I probably miss miss something xD
but u just have one functionality u can add Logo to the web now and store it in database !
hope i dont need to show u how to create form and view to it to upload and use of the controller
这篇关于如何在不使用第三方的情况下在asp.net中创建cms?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!