Click here to Skip to main content
15,889,909 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: How to configure sql server profiler to see sql for my session only Pin
Tridip Bhattacharjee13-Apr-17 2:57
professionalTridip Bhattacharjee13-Apr-17 2:57 
QuestionHow SSRS handle large data Pin
Tridip Bhattacharjee12-Apr-17 22:31
professionalTridip Bhattacharjee12-Apr-17 22:31 
QuestionMVC, my views can't see or reference the namespace MvcApplication in Global.asax Pin
jkirkerx12-Apr-17 8:50
professionaljkirkerx12-Apr-17 8:50 
AnswerRe: MVC, my views can't see or reference the namespace MvcApplication in Global.asax Pin
Afzaal Ahmad Zeeshan12-Apr-17 9:17
professionalAfzaal Ahmad Zeeshan12-Apr-17 9:17 
GeneralRe: MVC, my views can't see or reference the namespace MvcApplication in Global.asax Pin
jkirkerx12-Apr-17 10:17
professionaljkirkerx12-Apr-17 10:17 
QuestionIs there a control that displays a PDF and submits the pdf back to the server? Pin
Michael Clinton11-Apr-17 9:18
Michael Clinton11-Apr-17 9:18 
AnswerRe: Is there a control that displays a PDF and submits the pdf back to the server? Pin
ChetanAhire17-Apr-17 1:29
ChetanAhire17-Apr-17 1:29 
QuestionWriting multiple records to a binary file, reading the file records so I can add a record and write Pin
jkirkerx10-Apr-17 10:41
professionaljkirkerx10-Apr-17 10:41 
This is for a website that I'm building for my neighbor, and for future builds.
I don't want to use a database in this project, or XML unless I have to.
I thought I might be able to get away with using a binary file with multiple records to store contact us info.

So I have 1 record written so far. I'm trying to read the whole file and just add a record to it.
When I loop through the records, I get an error;
Unable to cast object of type 'System.Collections.Generic.List`1[genericMVC.Models.serialized_contactUs]' to type 'genericMVC.Models.serialized_contactUs'.

I thought I had casted it correctly, but this is the first test of the code, having to fix the issue of opening the file first.
The model is a typical model like in MVC, only I added serialized to the top of the class.
I haven't tried anything yet because I'm not sure if I'm on the right track here; or if my thought is even close to being possible.
string folderPath = HostingEnvironment.MapPath("~/App_Data/Database");
if (Directory.Exists(folderPath) == false)
    Directory.CreateDirectory(folderPath);

string binaryPath = folderPath += "\\contactUs_messages.bin";                
if (File.Exists(binaryPath))
{
    using (var fs = new FileStream(binaryPath, FileMode.Open))
    {
        if (fs != null)
        {
            // Read all the records and enter them into a generic collection
            List<serialized_contactUs> data = new List<serialized_contactUs>();
            var bf = new BinaryFormatter();
            while (fs.Position < fs.Length)
            {
                serialized_contactUs contact = (serialized_contactUs)bf.Deserialize(fs);
                data.Add(new serialized_contactUs()
                {
                    Name = contact.Name,
                    CompanyName = contact.CompanyName,
                    EmailAddress = contact.EmailAddress,
                    Phone_Number = contact.Phone_Number,
                    Phone_Ext = contact.Phone_Ext,
                    Phone_Mobile = contact.Phone_Mobile,
                    MessageContent = contact.MessageContent,
                    Time_Stamp = contact.Time_Stamp,
                    Time_Zone = contact.Time_Zone,
                    RememberMe = contact.RememberMe,
                    MailingList = contact.MailingList
                });
            }
            bf.Serialize(fs, data);
        }
If it ain't broke don't fix it

AnswerRe: Writing multiple records to a binary file, reading the file records so I can add a record and write Pin
jkirkerx10-Apr-17 11:38
professionaljkirkerx10-Apr-17 11:38 
QuestionXPagedList, StaticPageList, View, looping items with foreach, loops all the items and not the paginated ones Pin
jkirkerx10-Apr-17 9:17
professionaljkirkerx10-Apr-17 9:17 
AnswerRe: XPagedList, StaticPageList, View, looping items with foreach, loops all the items and not the paginated ones [solved] Pin
jkirkerx10-Apr-17 9:26
professionaljkirkerx10-Apr-17 9:26 
QuestionChange a color of single data labels in graph using crystal reports Pin
Member 1145200410-Apr-17 0:19
Member 1145200410-Apr-17 0:19 
QuestionWebhook receiver from the ground up using ASP.NET? Pin
cotsjdixon31-Mar-17 6:39
cotsjdixon31-Mar-17 6:39 
AnswerRe: Webhook receiver from the ground up using ASP.NET? Pin
Richard Deeming31-Mar-17 7:41
mveRichard Deeming31-Mar-17 7:41 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
cotsjdixon31-Mar-17 7:44
cotsjdixon31-Mar-17 7:44 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
Richard Deeming31-Mar-17 7:47
mveRichard Deeming31-Mar-17 7:47 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
cotsjdixon31-Mar-17 7:53
cotsjdixon31-Mar-17 7:53 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
Richard Deeming31-Mar-17 8:26
mveRichard Deeming31-Mar-17 8:26 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
Richard Deeming31-Mar-17 8:29
mveRichard Deeming31-Mar-17 8:29 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
cotsjdixon31-Mar-17 8:44
cotsjdixon31-Mar-17 8:44 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
Richard Deeming31-Mar-17 8:47
mveRichard Deeming31-Mar-17 8:47 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
cotsjdixon31-Mar-17 9:03
cotsjdixon31-Mar-17 9:03 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
Richard Deeming31-Mar-17 9:07
mveRichard Deeming31-Mar-17 9:07 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
cotsjdixon6-Apr-17 8:09
cotsjdixon6-Apr-17 8:09 
GeneralRe: Webhook receiver from the ground up using ASP.NET? Pin
Richard Deeming6-Apr-17 8:15
mveRichard Deeming6-Apr-17 8:15 

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.