Click here to Skip to main content
       

ASP.NET

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
QuestionEncrypting Database Credentialsmemberindian14322 Aug '12 - 15:20 
Hi All,
 
I have an asp.Net application which is using Entity Framework to connect to the Database and for DML operations. So I am using User Name and Password in my web config, now my question is, is there any way to hide these credentials or encrypt it. Which approach is best for security of Database credentials in Web config files. My ASP.Net UI is interacting with WCF service that is intern interacting with Entity Framework, in which projects I should keep these connection strings and what is the best approach for security.
 
Thanks in advance.
Thanks & Regards,
 
Abdul Aleem Mohammad
St Louis MO - USA

AnswerRe: Encrypting Database CredentialsmemberPaul Conrad22 Aug '12 - 16:08 
You may want to read up on Basic Security Practices for Web Applications[^]...
 
Specifically Access Databases Securely, there's a little bit on using integrated security. I hope this helps some.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus

AnswerRe: Encrypting Database CredentialsmvpNiladri_Biswas22 Aug '12 - 18:48 
indian143 wrote:
My ASP.Net UI is interacting with WCF service that is intern interacting with Entity Framework, in which projects I should keep these connection strings

 
It needs to be kept in the WCF service layer
 
<connectionStrings>
    <add name="XYZEntities" connectionString="metadata=res://*/DataAccessStrategy.Components.PartnerRenewal.csdl|res://*/DataAccessStrategy.Components.PartnerRenewal.ssdl|res://*/DataAccessStrategy.Components.PartnerRenewal.msl;provider=System.Data.SqlClient;provider connection string="Data Source=ServerName;Initial Catalog=DBName;User ID=username;Password=password;MultipleActiveResultSets=True"" providerName="System.Data.EntityClient"/>
  </connectionStrings>
 
You can refer the article on Task Management System that uses the similar technologies that you are using in your project. That may help you.[^]
Niladri Biswas
(Code Project MVP 2012)

QuestionAsp.Net - Oracle Connection failedmemberlalithafranklyn22 Aug '12 - 9:46 
Hi,
I am using oracle and c#.net. In my application, i need to populate a dropdownlist from one oracle db of a particular server/port/schema and populate another dropdownlist from another oracle db from another server/port.
 
Both the connections were success while connecting using oracle sql developer tool but in my application, i could not load the second control. Invalid username/password. logon failed error comes for the same credentials.
 
I am new to oracle. Please help me where i have to correct. Thanks in advance.
 
Thanks,
Lalitha
AnswerRe: Asp.Net - Oracle Connection failedmvpNiladri_Biswas22 Aug '12 - 18:29 
That means the supplied credentials are wrong (for the second case). Provide correct credentials and it should work. Check Checking Connection to Oracle Database for testing the connectivity.
 
In case , the credentials are correct, then may be the connection path is wrong
e.g. in
OracleConnection connection = new OracleConnection(@connectionPath);
 
check the value for @connectionPath e.g.
 
string connectionPath = "Data Source=orcl;User Id=scott;Password=tiger;Persist Security Info=False";
 
Hope this will help.
[^]
Niladri Biswas
(Code Project MVP 2012)

QuestionFTP virtual path .net 2.0memberlalithafranklyn22 Aug '12 - 9:31 
Hi,
 
I have given ftp server (say server), username, password and virtual directory path (say xxx/yyy/zzz) and a file name(file.txt).
I need to connect to a FTP server and check that file is exists in that virtual path.
When i tried using FtpWebRequest request = (FtpWebRequest) WebRequest.Create("ftp://server/xxx/yyy/zzz/file.txt");, it say invalid directory since the directory which i mentioned is not physically present in the ftp server.
 
Please help me with the best approach to connect to virtual directory in ftp server. I am using dot net 2.0 & c#.
 
thanks in advance.
Lalitha
AnswerRe: FTP virtual path .net 2.0memberSandip.Nascar22 Aug '12 - 11:12 
The code seems right.
 
// Get the object used to communicate with the server.
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.testdomain.com/test.htm");
 
But what is wrong is the directory path. As you said, the path doesn't exists, then you should not use that.
 
Do one thing,
Type: ftp://server from windows explorer
enter your login details and check the right path.
 
Hope this helps.
cheers
Questionasp.net mvc 3.0 -> showing description instead of ID in a toList() callmemberMarcel Vreuls (www.agentbase.nl)21 Aug '12 - 14:09 
Hi All,
 
I am fairly new to the MVC and am strugling with comboboxes/dropdown lists all day, but have the better part working. The following is my problem.
 
I have 2 models defined
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
 
namespace AgentBase.ContentRepository.Models
{
    public class cContent
    {
 
        public int ID { get; set; }
        public string CO_TITLE { get; set; }
        public string CO_TAGS { get; set; }
        public string CO_SUMMARY { get; set; }
        public bool CO_INTEXT { get; set; }
        public Int32 CO_TYPE { get; set; } //
        public decimal CO_SIZE { get; set; }
        public string CO_NOTES { get; set; }
        public string CO_COPYRIGHT { get; set; }
    }
 
}
 
and
 
using System;
using System.Data.Entity;
using System.Collections.Generic;
using System.Linq;
using System.Web;
 
namespace AgentBase.ContentRepository.Models
{
    public class cCategory
    {
        public int ID { get; set; }
        public string CA_DESCRIPTION { get; set; }
        public Int32 CA_PARENT { get; set; }
        public bool CA_ACTIVE { get; set; }
        
    }
 
}
 
Then i have 2 controllers defined
 
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AgentBase.ContentRepository.Models;
 
namespace AgentBase.ContentRepository.Controllers
{ 
    public class ContentRecordsController : Controller
    {
        private ContentRepositoryObjects db = new ContentRepositoryObjects();
        
 
        //
        // GET: /ContentRecords/
       
 
        public ViewResult Index()
        {
            //
            //------------------------------------------------------------------------
            var query = db.Categories.Select(c => new { c.ID, c.CA_DESCRIPTION });
            ViewBag.Categories = new SelectList(query.AsEnumerable(), "ID", "CA_DESCRIPTION");
           
            return View(db.ContentRecords.ToList());
            
        }
 
        //
        // GET: /ContentRecords/Details/5

        public ViewResult Details(int id)
        {
            cContent ccontent = db.ContentRecords.Find(id);
            //------------------------------------------------------------------------
            var query = db.Categories.Select(c => new { c.ID, c.CA_DESCRIPTION });
            ViewBag.Categories = new SelectList(query.AsEnumerable(), "ID", "CA_DESCRIPTION");
            return View(ccontent);
        }
 
        //
        // GET: /ContentRecords/Create

        public ActionResult Create()
        {
            //------------------------------------------------------------------------
            //var db = new NorthwindDataContext();           
            //------------------------------------------------------------------------
            var query = db.Categories.Select(c => new { c.ID, c.CA_DESCRIPTION });
            ViewBag.Categories = new SelectList(query.AsEnumerable(),"ID", "CA_DESCRIPTION");
            //------------------------------------------------------------------------
            return View();
        } 
 
        //
        // POST: /ContentRecords/Create

        [HttpPost]
        public ActionResult Create(cContent ccontent)
        {
            if (ModelState.IsValid)
            {
                db.ContentRecords.Add(ccontent);
                db.SaveChanges();
                return RedirectToAction("Index");  
            }
 
            return View(ccontent);
        }
        
        //
        // GET: /ContentRecords/Edit/5
 
        public ActionResult Edit(int id)
        {
            cContent ccontent = db.ContentRecords.Find(id);
            //Fill the Dropdown.
            //------------------------------------------------------------------------
            var query = db.Categories.Select(c => new { c.ID, c.CA_DESCRIPTION });
            ViewBag.Categories = new SelectList(query.AsEnumerable(), "ID", "CA_DESCRIPTION");
            //------------------------------------------------------------------------

            return View(ccontent);
        }
 
        //
        // POST: /ContentRecords/Edit/5

        [HttpPost]
        public ActionResult Edit(cContent ccontent)
        {
            if (ModelState.IsValid)
            {
                db.Entry(ccontent).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(ccontent);
        }
 
        //
        // GET: /ContentRecords/Delete/5
 
        public ActionResult Delete(int id)
        {
            cContent ccontent = db.ContentRecords.Find(id);
            return View(ccontent);
        }
 
        //
        // POST: /ContentRecords/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {            
            cContent ccontent = db.ContentRecords.Find(id);
            db.ContentRecords.Remove(ccontent);
            db.SaveChanges();
            return RedirectToAction("Index");
        }
 
        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}
 
and
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using AgentBase.ContentRepository.Models;
 
namespace AgentBase.ContentRepository.Controllers
{ 
    public class CategoryController : Controller
    {
        private ContentRepositoryObjects db = new ContentRepositoryObjects();
 
        //
        // GET: /Category/

        public ViewResult Index()
        {
            return View(db.Categories.ToList());
        }
 
        //
        // GET: /Category/Details/5

        public ViewResult Details(int id)
        {
            cCategory ccategory = db.Categories.Find(id);
            return View(ccategory);
        }
 
        //
        // GET: /Category/Create

        public ActionResult Create()
        {
            return View();
        } 
 
        //
        // POST: /Category/Create

        [HttpPost]
        public ActionResult Create(cCategory ccategory)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(ccategory);
                db.SaveChanges();
                return RedirectToAction("Index");  
            }
 
            return View(ccategory);
        }
        
        //
        // GET: /Category/Edit/5
 
        public ActionResult Edit(int id)
        {
            cCategory ccategory = db.Categories.Find(id);
            return View(ccategory);
        }
 
        //
        // POST: /Category/Edit/5

        [HttpPost]
        public ActionResult Edit(cCategory ccategory)
        {
            if (ModelState.IsValid)
            {
                db.Entry(ccategory).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(ccategory);
        }
 
        //
        // GET: /Category/Delete/5
 
        public ActionResult Delete(int id)
        {
            cCategory ccategory = db.Categories.Find(id);
            return View(ccategory);
        }
 
        //
        // POST: /Category/Delete/5

        [HttpPost, ActionName("Delete")]
        public ActionResult DeleteConfirmed(int id)
        {            
            cCategory ccategory = db.Categories.Find(id);
            db.Categories.Remove(ccategory);
            db.SaveChanges();
            return RedirectToAction("Index");
        }
 
        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}
 
then problem now is. That i have a list page where i call
 
 public ViewResult Index()
        {
            //
            //------------------------------------------------------------------------
            var query = db.Categories.Select(c => new { c.ID, c.CA_DESCRIPTION });
            ViewBag.Categories = new SelectList(query.AsEnumerable(), "ID","CA_DESCRIPTION");
           
            return View(db.ContentRecords.ToList());
            
        }
 
The index page shows me then all records from the ContentRecords.ToList function but that is showing me the CO_TYPE field ID, instead of the corresponding CA_DESCRIPTION from the categories entity. Because CO_TYPE is related to the CA_ID.
 
So how can I make it possible that the toList function:
a) returns values from two linked entities/models.
or
b) how can i create a new model based on two other more other models by joining them.
or
c) any other method i did not think of Wink | ;-)
 
I hope i have made a clear point of my problem. I am stuck any help will be appreciated.
Kind regards,
 
Marcel Vreuls
 
AgentBase
 
<<A good idea can change your life>>

QuestionUpdating or inserting entities using Entity Frameworkmemberindian14321 Aug '12 - 6:07 
Hi All,
 
I have an Asp.Net application in which I am trying to insert/upate a database table in the backend. But I am getting following message.
 
Unable to update the EntitySet 'message' because it has a DefiningQuery and no element exists in the element to support the current operation.
 
Can anybody help me please by giving any suggestions, links or code snippet. Mean time I will be googling about the exception.
 
Thanks in advance.
Thanks & Regards,
 
Abdul Aleem Mohammad
St Louis MO - USA

AnswerRe: Updating or inserting entities using Entity FrameworkmvpNiladri_Biswas22 Aug '12 - 18:50 
Hope this[^] answers your problem
Niladri Biswas
(Code Project MVP 2012)

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 25 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid