Quantcast
Channel: CodeProject Latest postings for ASP.NET
Viewing all 3938 articles
Browse latest View live

Code or a network stack control to change the network gateway inside my app

$
0
0
I am asked to find out if it is possible to switch the gateway inside my app that has the IE web control. I have a program that allows terminal users log into data service sites and get data back. The problem is that I need to change the gateway so that the data service comes from 2 gateway different gateways.

Thanks,

Can any one help me to post content on linked in asp.net?

$
0
0
Hi everyone.. I had tried to post on linkedin using many apis in asp.net but not succeeded. Please any one show me how to do that?

ASP.NET MVC4 / WebAPI OAuth - DotNetOpenAuth

$
0
0
Hi All,

I've been using DotNetOpenAuth in my MVC / WebAPI solutions for a while now and I've attempted to upgrade to MVC5 and WebAPI2 twice now and due to so many issues with DotNetOpenAuth I've failed both times to get it all working.

Since this project seems to be either dead or moving at a horrifically slow pace what are the alternatives for both a client and server solution?

I'm stumped at how some people seem to have gotten it to work as I'm failing miserably.

Thanks,

James

display day name of selected date

$
0
0
How to display day name on selected date in textbox.

PS. Using VS 2013, ASP.NET

The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available

$
0
0
Please help me I am using this script..
FIND THE FULL CODE HERE

http://pastebin.com/qY1cN1ry[^]
 
 
publicvoid sendemail(int MemberId, DataTable Member, int rowNo)
        {
            MailMessage msgMail = new MailMessage();
 
            msgMail.To = Member.Rows[rowNo]["EmailID"].ToString();
            msgMail.From = "admin@auditionbollywood.com"; 
            msgMail.Subject = "Auditions BollyWood Account Expire";
            msgMail.BodyFormat = MailFormat.Text;
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("Hi !\n\n");
            sb.AppendFormat("Your Audition Bollywood Account has been expired.Please pay the payment for activation.\n");
            sb.AppendFormat("Click the below link to pay to activate your account\n");
            string link = string.Format("http://www.auditionbollywood.com/paymentrenewal.aspx?MemberId={0}", MemberId.ToString());
            sb.Append(link);
            sb.AppendFormat("\n\nThank You");
            msgMail.Body = sb.ToString();
            msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "mail.auditionbollywood.com");
            msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", 587);
            msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", 2);
            msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
            msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "admin@auditionbollywood.com");
            msgMail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "**********");
            SmtpMail.SmtpServer = "mail.auditionbollywood.com";
            SmtpMail.Send(msgMail);
        }

XmlTextWriter.Create(MemoryStream, xmlSettings)

$
0
0
So this is related to my VB post on FirstData V19 SOAP, but is the final piece of the puzzle.
I finally figured out why I can't match the Transmission of the SOAP Body to the copy of the the SOAP Body.
My Soap Body Contains and empty element for Address 2. And the transmitted SOAP Body just closes the empty element. So the 2 don't match, and I get the wrong content digest.

If there amy way using XMLWriter that I can close empty elements? Or will I have to do further manipulation?

SOAP Examples
'Copy of SOAP Body
<Address1 xsi:type="xsd:string">1234 Main Street</Address1><Address2 xsi:type="xsd:string"></Address2>
'Actual SOAP Body Transmitted.
<Address1 xsi:type="xsd:string">1234 Main Street</Address1><Address2 xsi:type="xsd:string"/>

My Code
Dim buffer As MessageBuffer = request.CreateBufferedCopy(Int32.MaxValue)
request = buffer.CreateMessage
 
Dim msg As Message = buffer.CreateMessage
Dim encoder As UTF8Encoding = New UTF8Encoding
 
Dim txn As MemoryStream = New MemoryStream
Dim xmlSettings AsNew XmlWriterSettings
With xmlSettings
    .OmitXmlDeclaration = TrueEndWith 
Using xmlWriter As XmlWriter = xmlWriter.Create(txn, xmlSettings)
    Using writer As XmlDictionaryWriter = XmlDictionaryWriter.CreateDictionaryWriter(xmlWriter)
 
        msg.WriteStartEnvelope(writer)
        msg.WriteStartBody(writer)
        msg.WriteBodyContents(writer)
        xmlWriter.WriteEndElement()
        xmlWriter.WriteEndElement()
        writer.Flush()
 
    EndUsingEndUsing 
'Convert the MemoryStream to a Byte Array
Dim txn_string AsString = encoder.GetString(txn.ToArray()).Replace(" />", "/>")
Dim xml_bytes() AsByte = encoder.GetBytes(txn_string)

Single Page Application based on .NET

$
0
0
I am novice in programming and I have been working out developing Learning Management System to facilate the teaching and learning in the community based schools and colleges. I am also trying to build Single Page Application in MVC4 but I have some queries regarding whether it will be handy to use Ajax or how we develope SPA in MVC4 framework without using Ajax?
I will be pleased having your additional ideas.

Thank you in advance

Regards
Ishwor Khanal

Using Entity Framework on a Web Forms Website

$
0
0
I have a Webforms WebApp, and I'm toying with the idea of switching to Entity Framework 6.0 on it.
My idea is to create a dataAccessLayer.dll.
So I decided to spend a day testing the idea, and I'm not sure if I should create a edmx file, or if I'll suppose to hard code using models in a class.
I did import or create a edmx file, but creating the relationships is vague to me, and can't seem to find a decent lesson on it.
I created a couple class files, but the examples I used seem vague as well. This is what the Contoso University Example used in VB.

Example of one of my class files
Imports System.Data.Entity
Imports System.Collections.Generic
Imports System.ComponentModel.DataAnnotations
Imports System.Data.Entity.Infrastructure
 
Namespace Models
 
    Public Class Customer_Accounts
 
        Public Property ID As Integer
        Public Property Advanced As Boolean
        Public Property AccountName As String
        Public Property FirstName As String
        Public Property LastName As String
        Public Property EmailAddress As String
        Public Property Password As Byte
        Public Property PasswordSalt As Byte
        Public Property PhraseHint As String
        Public Property PhraseAnwser As String
        Public Property DateOpened As DateTime
        Public Property Lockout As Boolean
        Public Property LastLogin As DateTime
        Public Property IPAddress As String 
    End Class
 
End Namespace

I did a job a couple of months ago in c#, and this guy made his class like this, I can see how this can create the tables in the database.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
using System.Linq;
using DataAccessLibrary.Models;
 
namespace DataAccessLayer.Models
{
    ///<summary>/// Class Customer.
///</summary>publicclass Customer : EntityBase, IValidatableObject
    {
        #region Public Constructors
 
        ///<summary>///</summary>public Customer()
        {
            SalesOrders = new ObservableListSource<SalesOrderHeader>();
            Addresses = new ObservableListSource<CustomerAddress>();
        }
 
        #endregion Public Constructors
 
        #region Public Properties
 
        ///<summary>/// Gets or sets the addresses.
///</summary>///<value>The addresses.</value>        [Description("List of addresses for this customer")]
        publicvirtual ObservableListSource<CustomerAddress> Addresses { get; set; }
 
        ///<summary>/// Gets or sets the name of the business.
///</summary>///<value>The name of the business.</value>        [Description("This customer's business name.")]
        [DisplayName("Business Name")]
        [StringLength(45)]
        [Index(IsUnique = true)]
        publicstring BusinessName { get; set; }

I can't see how a table can be created from this class.

Im just looking for some suggestions on how you would do this, or if it even can be done.

Connection to vpn using .bat file

$
0
0
Hi,
can anybody help me to coonect to vpn using .bat file ?
i want to create a .bat file to connect to vpn so that i don't have to pass username and password details to connect to vpn .
i just connected to vpn by double clicking on .bat file.

MVC Role users error instance

$
0
0
I created a few roles for users and I'm trying to assing a role to a specific user but I get this error:
<pre lang="c#">An exception of type 'System.NullReferenceException' occurred in Microsoft.Owin.Host.SystemWeb.dll but was not handled in user code
 
Additional information: Object reference not set to an instance of an object.
 
If there is a handler forthis exception, the program may be safely continued.
and
Line 47:             get
Line 48:             {
Line 49:                 return _userManager ?? HttpContext.GetOwinContext().GetUserManager<ApplicationUserManager>();
Line 50:             }
Line 51:             privateset

In AccountController I don't have anything for this option. This is the function from Controller that should assing the role:
[HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult RoleAddToUser(string UserName, string RoleName)
        {
            ApplicationUser user = context.Users.Where(u => u.UserName.Equals(UserName, StringComparison.CurrentCultureIgnoreCase)).FirstOrDefault();
            var account = new AccountController();
            account.UserManager.AddToRole(user.Id, "RoleName");
 
<pre>
        ViewBag.ResultMessage = "Role created successfully !";
 
        // prepopulat roles for the view dropdown
var list = context.Roles.OrderBy(r => r.Name).ToList().Select(rr => new SelectListItem { Value = rr.Name.ToString(), Text = rr.Name }).ToList();
        ViewBag.Roles = list;
 
        return View("ManageUserRoles");
    }</pre>

Where is the mistake?

Single quote character in query string causes SQL injection

$
0
0
I was just wondering if adding a single quote mark to an embedded query string parameter in a hard coded SQL query could cause a SQL injection error? As you can see after the @docNum parameter I am using both the percent and single quote characters. Somewhere in my code something is causing the error. Now if I were to only use a single percent character % instead of both the % and the single quote character %' unlike in the StringBuilder appended line below would this the stop the error from occurring?

sb.Append("AND docNumTCN LIKE  @docNum%' "

A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

$
0
0
I am trying to send email using gmail smtp. In localhost it's working perfectly but when I'm uploading to the server it's throwing the following exception.

Quote:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.200.109:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.Send(MailMessage message) --- End of inner exception stack trace --- at System.Net.Mail.SmtpClient.Send(MailMessage message) at contact.btnSubmit_ServerClick(Object sender, EventArgs e) in c:\inetpub\wwwroot\contact.aspx.cs:line 156System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.200.109:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception) --- End of inner exception stack trace --- at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6) at System.Net.PooledStream.Activate(Object owningObject, Boolean async, GeneralAsyncDelegate asyncCallback) at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout) at System.Net.Mail.SmtpConnection.GetConnection(ServicePoint servicePoint) at System.Net.Mail.SmtpClient.Send(MailMessage message)System.Net.Sockets.SocketException (0x80004005): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 74.125.200.109:587 at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress) at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)


my code is
var fromAddress = new MailAddress("abcd@gmail.com", "from");
var toAddress = new MailAddress("cdef@yahoo.com", "To Name");
conststring fromPassword = "password";
conststring subject = "Hello";
conststring body = "Hi there";
 
var smtp = new SmtpClient
{
    Host = "smtp.gmail.com",
    Port = 587,
    EnableSsl = true,
    DeliveryMethod = SmtpDeliveryMethod.Network,
    UseDefaultCredentials = false,
    Credentials = new NetworkCredential(fromAddress.Address, fromPassword)
};
using (var messag = new MailMessage(fromAddress, toAddress)
{
    Subject = subject,
    Body = body
})
 

 
    try
    {
        smtp.Send(messag);
    }
 
    catch (Exception ex)
    {
        // call.InnerText = "mail could not be sent" + ex.Message;
        Exception ex2 = ex;
        string errorMessage = string.Empty;
        while (ex2 != null)
        {
            errorMessage += ex2.ToString();
            ex2 = ex2.InnerException;
        }
        //  HttpContext.Current.Response.Write(errorMessage);
    }
Please help.

Content binding

$
0
0
what is meaning of it..please elobrate

ASP.net

$
0
0
Hello,

i am a beginner with basic knowledge of c++,C# and ASP.net, Java script. I also learned to create dummy project by ASP.net but not able to create live project but that has three year gap due to illness. . I want to start it again please let me know what would be the right direction for that

RDLC Report in Asp.Net

$
0
0
Hi All,

I used the rdlc report in my Web form application c#, and in the development environment every thing work fine, but when publish the Application Over the IIS the report viewer didn't show any thing and an error occurred.
"System.NotSupportedException: The given path's format is not supported."

Please let me know how to solve this issue.

Thanks All

oAuth Custom Service with MVC

$
0
0
Hi All.

In my e-commerce web application, im using one of finance application to transfer invoices, therefore i have to use there o Auth api service and Authenticate from them. Can you please share some sample for create custom oAuth service which will open as Pop-up and asking the credentials...etc. Same time i need retrieve the token from them.

Thanks

Entity Design for web service

$
0
0
My client will be sending the request as described below in SOAP format.
<RequestTimestamp>2014-08-22T11:28:00Z</RequestTimestamp><SystemID>TestProcessor</SystemID><Version>1<Version><QWID>201507080000001</QWID><QWID>201507080000010</QWID><QWID>201507080000001</QWID><QWID>201507080000010</QWID><QWID>201507080000001</QWID><QWID>201507080000010</QWID><CHL>201507080000010</CHL>

In every request, QWID should come as batch and I proposed below entity design to adopt above data.

publicclass APIRequest
{
 
    [DataMember]
    public DateTime RequestTimestamp;
 
    [DataMember]
    publicstring SystemID;
 
    [DataMember]
    publicint Version;
 
    [DataMember]
    publicstring[] QWID;
 
    [DataMember]
    publicstring CHL;
    
}

With above entity design, SOAP request generated as

<requestxmlns:a="http://schemas.datacontract.org/2004/07/QWID.Services"xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><a:RequestTimestamp>0001-01-01T00:00:00</a:RequestTimestamp><a:SystemID>WireSystem_001</a:SystemID><a:Version>0</a:Version><a:QWIDxmlns:b="http://schemas.microsoft.com/2003/10/Serialization/Arrays"> 
          <b:string>20141023010232_ORG99000002_CTR.fedwire</b:string> 
          <b:string>20141023010842_ORG99000001_CTR.fedwire</b:string></a:QWID></request>

My client expecting the SOAP request in the form of <QWID>201507080000001</QWID> instead of coming under <QWID><b:string>20141023010232_ORG99000002_CTR.fedwire</b:string></QWID> as string tag.
 
How do i do the entity design (without grouping of QWID) to achieve client expectation as described above? Please help me on this?

Gridview

how to insert data in table with foreign key

$
0
0
how to insert data into table with foreign key using the max id of primary key table.

using asp.net VS2013, DB-Ms-Access.

getting following error when i try to insert data using "select max(id) from table 1"

thirdparty cookies

$
0
0
Hi Friends ,

iam using one iframe in my application. In that iframe iam Display another web application in that have registration form with captcha , when our submit the Registration its working in chrome and mozilla but its Not Working in IE because of third party cookies are Disable by Default. how can i enable third party cookies using code.
Viewing all 3938 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>