Showing posts with label Dot net. Show all posts
Showing posts with label Dot net. Show all posts

Monday, June 20, 2016

DGML

A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'Id'.

This Exception will occur while updating the database at Savechanges( ).When this exception occur while updating database.
                 
----->Update EDMX file inorder to overcome this exception.

Sunday, June 19, 2016

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.

sol: False to true

  <system.web>
    <compilation debug="false" targetFramework="4.0"/>
  </system.web>


  <system.web>
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>


Edit any page

run this script in browser...

javascript:document.body.contentEditable = 'true'; document.designMode = 'on'; void 0

Thursday, June 16, 2016

Remote Debugging a Window Azure Web Site with Visual Studio 2013

In the Azure SDK 2.2 we released remote debugging support for Windows Azure Cloud Services. You can read more about that release at Scott Guthrie’s blog post Windows Azure: Announcing release of Windows Azure SDK 2.2 (with lots of goodies). You can find more info on Windows Azure Web Sites diagnostics and debugging at our docs for Web Sites diagnostics and debugging as well.
When we released the Azure SDK 2.2 the server side support for remote debugging Windows Azure Web Sites was not yet in production. Because of this the command was not shown in Visual Studio. We have now published the server side support in Windows Azure Web Sites, and the feature is now automatically enabled in Visual Studio.
In this post you will find the download links required to try out the new features as well as more info about the support.

How to get the new features?

In order to remotely debug your site you will need to download and install the following.
· Any version of Visual Studio 2013 which supports remote debugging
After installing the Azure SDK 2.2 you will now see a new menu option, Attach Debugger, for your Azure Web Sites. In the image below you’ll find this new menu option.
image
Now let’s see how you can use this new feature.

Remote debugging walkthrough

For a new site running in Windows Azure Web Site you’ll need to follow the following steps to get your remote debugging session started.
2. Invoke the Attach Debugger menu option in Server Explorer
To have the best debugging experience you should publish your site using the Debug build configuration. You can configure this for your publish profile on the Settings tab of the Web Publish dialog. The drop down is shown in the following image.
clip_image002
After publishing your application you can use the Server Explorer in Visual Studio to access your web sites. If you haven’t already you may need to sign in to Windows Azure in Visual Studio. You can do this using the Connect to Windows Azure button on the Server Explorer. See the image below for that button.
clip_image003
After signing in you will see your Web Sites under the Windows Azure node in Server Explorer. Right click on the site that you would like to debug and select Attach Debugger. When this is invoked the remote debugging agent will be started on your web site, you site is restarted with the agent attached, your default browser will be opened to the URL of your site, and Visual Studio will attach the remote debugger. The first time you do this the delay will be about 20 seconds, but subsequent usages will attach much quicker. If you disable the remote debugger option in the portal you’ll experience the ~20 second delay again.
After that you can debug your remote site as you would your local project. You can step through code, set breakpoints, break on exceptions, evaluate expressions, and all the other goodness you are used to.
Note: currently the support here is designed for single instance sites. If you attach to a web site running multiple instances, you will attach to a random instance. In the future we may look at providing a better experience here, but we do not have any specific plans yet.
For more info on remote debugging Windows Azure Web Sites you can visit http://www.windowsazure.com/en-us/develop/net/tutorials/troubleshoot-web-sites-in-visual-studio/#remotedebug.

Remote debugging with Visual Studio 2012

You can also remotely debug your Windows Azure Web Site with Visual Studio 2012, but you’ll need to configure a few things manually for now. We are working to bring the same experience for remote debugging to Visual Studio 2012 but we are not there yet. For now you can use the steps below for Visual Studio 2012.
  1. In the Windows Azure Management Portal, go to the Configure tab for your web site, and then scroll down to the Site Diagnostics section
  2. Set Remote Debugging to On, and set Remote Debugging Visual Studio Version to 2012 image
  3. In the Visual Studio Debug menu, click Attach to Process
  4. In the Qualifier box, enter the URL for your web site, without the http:// prefix
  5. Select Show processes from all users
  6. When you’re prompted for credentials, enter the user name and password that has permissions to publish the web site. To get these credentials, go to the Dashboard tab for your web site in the management portal and click Download the publish profile. Open the file in a text editor, and you’ll find the user name and password after the first occurrences of userName= and userPWD=.
  7. When the processes appear in the Available Processes table, select w3wp.exe, and then click Attach.
  8. Open a browser to your site URL.
    • You might have to wait 20 seconds or so while Windows Azure sets up the server for debugging. This delay only happens the first time you run in debug mode on a web site. Subsequent times within the next 48 hours when you start debugging again there won’t be a delay.


Tuesday, June 14, 2016

How to send a mail using C#

 private void send-mail( )

            {
            string senderID = "sender@gmail.com";// use sender’s email id here..
             const string senderPassword ="password of sender"; // sender password here…
           
                  Console.WriteLine("sending mails......");
                  SmtpClient smtp = new SmtpClient
                  {
                   Host = "smtp.gmail.com", // smtp server address here…
                   Port = 587,
                  EnableSsl = true,
                  DeliveryMethod = SmtpDeliveryMethod.Network,
                   Credentials = new System.Net.NetworkCredential(senderID, senderPassword),
                  Timeout = 30000,
                  };


                 MailMessage message = new MailMessage(senderID, "receiver@gmail.com");
                 message.subject= "hi ";
                  message.Body="   ur body  ";
                 smtp.Send(message);
                Console.WriteLine("mail sended successfully");
               }

Monday, June 6, 2016

Error : Maximum request length exceeded

in web.config file
Sol: 
<compilation debug="true" targetFramework="4.5"/>
    <httpRuntime targetFramework="4.5" maxRequestLength="2147483647" executionTimeout="1600" requestLengthDiskThreshold="2147483647"/>
  
    <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOn" timeout="2880"/>
    </authentication>
   
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147483647"/>
      </requestFiltering>
    </security>

   </system.webServer>

object reference not set to an instance of an object. meaning

Object reference not set to an instance of an object.

Null Reference Exception:

    In simple words this error means that you are trying to use a reference of an object which is "null".
Means, you haven't initialize  it. If you have to use any object you have to initialize it.

                              This is a RUN TIME exception.

Tuesday, May 31, 2016

Error occurred during a cryptographic operation. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Security.Cryptography.CryptographicException: Error occurred during a cryptographic operation.

Server Error in '/' Application.

Error occurred during a cryptographic operation.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Cryptography.CryptographicException: Error occurred during a cryptographic operation.

Source Error:


Line 53:                     //var prin = new GenericPrincipal(id, userRoles);
Line 54:                     //HttpContext.Current.User = prin;
Line 55:                     var ticket = FormsAuthentication.Decrypt(encTicket);
Line 56:                     var id = new UserIdentity(ticket);
Line 57:                     string[] userRoles = { "A" };


Source File: c:\Naresh\                                        Global.asax.cs    Line: 55

Stack Trace:


[CryptographicException: Error occurred during a cryptographic operation.]
   System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.Homogen
izeErrors(Func`2 func, Byte[] input) +115
   System.Web.Security.Cryptography.HomogenizingCryptoServiceWrapper.Unprot
ect(Byte[] protectedData) +70
   System.Web.Security.FormsAuthentication.Decrypt(String encryptedTicket)
 +9692626
   CanPayApp.MvcApplication.MvcApplication_PostAuthenticateRequest(Object
 sender, EventArgs e) in c:\Naresh\05 31 2016\CanPayApp\CanPayApp\Global
.asax.cs:55
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecut
ionStep.Execute() +141
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&
 completedSynchronously) +69



Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1055.0

=============================================================================
=Cleanup code and open... 

For anyone who hasn't solved their problem, I was missing the "machineKey" entry for encrypt/decrypt in my web.config

=
Try clearing your cache and cookies in order to mitigate the error. I suspect some sort of error occurred when information was sent to or from the server.

Friday, May 13, 2016

The localhost page isn’t working in visual studio

Resolved::: solution> project properties> change iis express port number ----

Wednesday, October 21, 2015

LINQPad USE


LINQPad allows you to execute single LINQ commands against an existing EF model, or even to write dot net code in the editor and execute it like a little dynamic dot net environment.  The main application is free, but there is an auto-complete feature to the editor that you must pay in order to activate. Believe me it is worth it to pay for the license, you also support the author and show him the application is worthMONEY .  The license is very inexpensive and well worth the price in order to get intellisense like behavior on your LINQ queries.
The first couple versions I played with worked great with SQL Server, but could not load the VistaDB EF provider.  I was bummed, but at least I could debug my queries against SQL Server, and then run against VistaDB to make sure it worked the same way.  But I recently got an email from the author of LINQPad that it could load VistaDB, in version 2.


Monday, October 19, 2015

Email Templates

Sample
Main program
static void Main(string[] args)
        {
            new Email().Run();
        }


Cs.file

public class Email
    {
       public void Run()
       {
           try
           {
               System.Net.Mail.MailMessage newmsg = new System.Net.Mail.MailMessage();

               newmsg.From = new MailAddress("from address full");

               newmsg.Subject = "Testing2";
               newmsg.To.Add("to address");
               //newmsg.To.Add("choulla.naresh@gmail.com");
               newmsg.Body = "Hellooooo2";
               SmtpClient smtp = new SmtpClient();
               smtp.Host = "host address";
//port number
               smtp.Port = "port number";
               smtp.Credentials = new System.Net.NetworkCredential("username",                      "password");
               //smtp.UseDefaultCredentials = false;
               smtp.EnableSsl = false;
               smtp.Send(newmsg);
           }
           catch(Exception Ex)
           {
               //smtp.Send(msg);
           }
       }

    }

Tuesday, October 6, 2015

Read Xml data and display Jquary

<?xml version="1.0" encoding="utf-8" ?>
        <booklist>
            <book>
                <title>Naresh</title>
                <author>Naresh1</author>
                <genre>Classic</genre>
            </book>
            <book>
                <title>abc</title>
                <author>def</author>
                <genre>Classic</genre>
            </book>
            <book>
                <title>qqq</title>
                <author>asd</author>
                <genre>www</genre>
            </book>
          
        </booklist>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                $("#contentArea").append("<ul></ul>");
                $.ajax({
                    type: "GET",
                    url: "data.xml",
                    dataType: "xml",
                    success: function (xml) {
                        $(xml).find('Book').each(function () {
                            var sTitle = $(this).find('Title').text();
                            var sAuthor = $(this).find('Author').text();
                            var sGenre = $(this).find('Genre').text();
                            $("<li></li>").html(sTitle + ", " + sAuthor + "," + sGenre).appendTo("#contentArea ul");
                        });
                    },
                    error: function () {
                        alert("An unexpected error has occurred during processing.");
                    }
                });
            });
        </script>

     
        <div id="contentArea">

        </div>