Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Saturday, March 31, 2012

The ASPNET Sql Server Account

What's the proper way to setup this account in SQL Server?

We're using Windows authentication on our network and to give any user permission in the database I have to grant it to the ASPNET account. This seems to defeat the purpose of using Windows authentication because anyone that opens the ASP.NET page will have those rights in the database even if they aren't listed as a user in the DB.

For example, I give read-only rights to the ASPNET account and even if I give an individual user db_datawriter rights, they still cannot write to the DB unless I grant the ASPNET account db_datawriter rights. Then anyone can save/modify the data.Is SQL server installed on the same machine as IIS?

This will have an impace on how the ASPNET user operates.
Both are on the same machine.
set impersonation on in the web config file

<impersonate=true/>

Or something to that affect...
This is a good article on the microsoft site, it explains the different methods for accessing SQL server.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconaccessingsqlserverfromwebapplication.asp

This is also a good article.
http://support.microsoft.com/default.aspx?scid=kb;en-us;815154
Originally posted by hellswraith
set impersonation on in the web config file

<impersonate=true/>

Or something to that affect...

that did the trick. well actually it was

<identity impersonate="true" />

then you can get rid of the ASPNET account if using Windows authentication.
Does anyone know if this impersonate would work if IIS and SQL server are on different machines.
I have a feeling it won't but I am happy to be told I am wrong.
I'm pretty sure they have to be on the same machine. I think I read that on MSDN.
That was my understanding. The first article in on of my previous posts talks about it.
Sometimes I wonder if I understand it the way they mean it.
From my interpretation of the article, You need to have the SQL Server and IIS (web server) on the same machine if you want to use Windows authentication OR anonymous access with the ASPNET account.

If you want to access the SQL Server using a Mapped Windows Domain User or prompting for the username and password and passing them as credentials then you don't need the SQL Server and web server on the same machine.
I went on ASP.NET training last week where IIS and SQL were on the same server, the ASPNET account was used.
We came away thinking that is how it naturally worked. It took me half a day and some searching to find out it wasn't so cut and dried.

Monday, March 26, 2012

The control values are not sent to the form code.

I am new to Web Forms and I ported my little app from Windows Forms to
ASP.NET and I am wondering why some things are not working as before.
Although I figured most of them, one of them is that on my form I have input
fields and a button causing to store all the input fields into the database.
However, when in the button OnClick event I gather all the form control
values by either getting txtBox.Text or lstChoice.SelectedItem, all the
values are not equal to the user choices, but to the values last set by the
form programatically on Form Load. It looks that I am missing some event tha
t
sends the user control values from the client to the server.
Am I missing something?
Thank you
Cezar MartCezar:
Take a look at http://openmymind.net/FAQ.aspx?documentId=2
short answer is you need to wrap the code which initially sets the values in
a if not page.IsPostback then
Karl
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"Cezar" <Cezar@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:E8548106-843F-4252-A39F-4C40BC63774B@dotnet.itags.org.microsoft.com...
> I am new to Web Forms and I ported my little app from Windows Forms to
> ASP.NET and I am wondering why some things are not working as before.
> Although I figured most of them, one of them is that on my form I have
input
> fields and a button causing to store all the input fields into the
database.
> However, when in the button OnClick event I gather all the form control
> values by either getting txtBox.Text or lstChoice.SelectedItem, all the
> values are not equal to the user choices, but to the values last set by
the
> form programatically on Form Load. It looks that I am missing some event
that
> sends the user control values from the client to the server.
> Am I missing something?
> Thank you
> Cezar Mart
>

The control values are not sent to the form code.

I am new to Web Forms and I ported my little app from Windows Forms to
ASP.NET and I am wondering why some things are not working as before.
Although I figured most of them, one of them is that on my form I have input
fields and a button causing to store all the input fields into the database.
However, when in the button OnClick event I gather all the form control
values by either getting txtBox.Text or lstChoice.SelectedItem, all the
values are not equal to the user choices, but to the values last set by the
form programatically on Form Load. It looks that I am missing some event that
sends the user control values from the client to the server.
Am I missing something?
Thank you
Cezar MartCezar:
Take a look at http://openmymind.net/FAQ.aspx?documentId=2

short answer is you need to wrap the code which initially sets the values in
a if not page.IsPostback then

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/ - New and Improved (yes, the popup is annoying)
http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)

"Cezar" <Cezar@dotnet.itags.org.discussions.microsoft.com> wrote in message
news:E8548106-843F-4252-A39F-4C40BC63774B@dotnet.itags.org.microsoft.com...
> I am new to Web Forms and I ported my little app from Windows Forms to
> ASP.NET and I am wondering why some things are not working as before.
> Although I figured most of them, one of them is that on my form I have
input
> fields and a button causing to store all the input fields into the
database.
> However, when in the button OnClick event I gather all the form control
> values by either getting txtBox.Text or lstChoice.SelectedItem, all the
> values are not equal to the user choices, but to the values last set by
the
> form programatically on Form Load. It looks that I am missing some event
that
> sends the user control values from the client to the server.
> Am I missing something?
> Thank you
> Cezar Mart

Saturday, March 24, 2012

The data at the root level is invalid. Line 1, position 1

Hi there,
I got this message ("The data at the root level is invalid. Line 1, position
1.") when I moved the application from my workstation to Windows 2003 web
server. But the wired thing the whole application works fine on my
workstation which running Windows XP prof sp 2 edition.
Please help me out
Thanks
AlanOn Fri, 05 Aug 2005 12:24:33 -0400, Alan Wang wrote:

> Hi there,
> I got this message ("The data at the root level is invalid. Line 1, positi
on
> 1.") when I moved the application from my workstation to Windows 2003 web
> server. But the wired thing the whole application works fine on my
> workstation which running Windows XP prof sp 2 edition.
> Please help me out
> Thanks
> Alan
If ds is your DataSet, you can refer to the tables by name as in
ds.Tables("yourTableName")

The data at the root level is invalid. Line 1, position 1

Hi there,

I got this message ("The data at the root level is invalid. Line 1, position
1.") when I moved the application from my workstation to Windows 2003 web
server. But the wired thing the whole application works fine on my
workstation which running Windows xp prof sp 2 edition.

Please help me out

Thanks

AlanOn Fri, 05 Aug 2005 12:24:33 -0400, Alan Wang wrote:

> Hi there,
> I got this message ("The data at the root level is invalid. Line 1, position
> 1.") when I moved the application from my workstation to Windows 2003 web
> server. But the wired thing the whole application works fine on my
> workstation which running Windows xp prof sp 2 edition.
> Please help me out
> Thanks
> Alan
If ds is your DataSet, you can refer to the tables by name as in
ds.Tables("yourTableName")

The data is invalid - windows media player error

I cannot seem to get a wmv file to stream from asp.net. I have tried
the following code.
I need to be able to use either response.outpustream or
response.binarywrite since
I will be getting the file from an sql server image field. Other types
of files such as gif or pdf work fine. Here is the code for the wmv:
Dim sql As String
sql = "select * from TblBlobs where blob_id = " & iBlobId
Dim da As New SqlDataAdapter(sql, cn)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet
cn.Open()
da.Fill(ds, "Default")
Dim myRow As DataRow
myRow = ds.Tables("Default").Rows(0)
Dim MyData() As Byte
MyData = myRow("filedata")
Response.ClearContent()
Response.ClearHeaders()
Response.Buffer = False
Response.ContentType = "video/x-ms-wmv"
Response.OutputStream.Write(MyData, 0, MyData.Length)
Response.Flush()
Response.Close()
MyCB = Nothing
ds = Nothing
da = Nothing
cn.Close()
cn = Nothing
When the user clicks on a button to run this code, the error "The data
is invalid" is displayed from windows media player. I cannot figure
out what is specific about wmv's that they will not stream.
Thanks Before Hand,
AdielUpdate:
The error when testing on system with Windows Media Player Version
7.10.00.3077 is "The data is invalid"
The error when testing on system with Windows Media Player Version
10.00.00.3700 is "Windows Media Player cannot play the file. The
Player might not support the file type or might not support the codec
that was used to compress the file." and if you click on "More
Information", the error is "C00D1199: Cannot play the file" Error ID =
0xC00D1199, Condition ID = 0x00000000.
Thanks,
Adiel

The data is invalid - windows media player error

I cannot seem to get a wmv file to stream from asp.net. I have tried
the following code.
I need to be able to use either response.outpustream or
response.binarywrite since
I will be getting the file from an sql server image field. Other types
of files such as gif or pdf work fine. Here is the code for the wmv:

Dim sql As String

sql = "select * from TblBlobs where blob_id = " & iBlobId

Dim da As New SqlDataAdapter(sql, cn)
Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
Dim ds As New DataSet

cn.Open()
da.Fill(ds, "Default")
Dim myRow As DataRow
myRow = ds.Tables("Default").Rows(0)

Dim MyData() As Byte
MyData = myRow("filedata")

Response.ClearContent()
Response.ClearHeaders()
Response.Buffer = False

Response.ContentType = "video/x-ms-wmv"

Response.OutputStream.Write(MyData, 0, MyData.Length)
Response.Flush()
Response.Close()

MyCB = Nothing
ds = Nothing
da = Nothing

cn.Close()
cn = Nothing

When the user clicks on a button to run this code, the error "The data
is invalid" is displayed from windows media player. I cannot figure
out what is specific about wmv's that they will not stream.

Thanks Before Hand,
AdielCAn you scesfully download the WMV file.

"adiel_g@dotnet.itags.org.hotmail.com" wrote:

> I cannot seem to get a wmv file to stream from asp.net. I have tried
> the following code.
> I need to be able to use either response.outpustream or
> response.binarywrite since
> I will be getting the file from an sql server image field. Other types
> of files such as gif or pdf work fine. Here is the code for the wmv:
>
> Dim sql As String
> sql = "select * from TblBlobs where blob_id = " & iBlobId
> Dim da As New SqlDataAdapter(sql, cn)
> Dim MyCB As SqlCommandBuilder = New SqlCommandBuilder(da)
> Dim ds As New DataSet
> cn.Open()
> da.Fill(ds, "Default")
> Dim myRow As DataRow
> myRow = ds.Tables("Default").Rows(0)
> Dim MyData() As Byte
> MyData = myRow("filedata")
> Response.ClearContent()
> Response.ClearHeaders()
> Response.Buffer = False
> Response.ContentType = "video/x-ms-wmv"
> Response.OutputStream.Write(MyData, 0, MyData.Length)
> Response.Flush()
> Response.Close()
> MyCB = Nothing
> ds = Nothing
> da = Nothing
> cn.Close()
> cn = Nothing
>
> When the user clicks on a button to run this code, the error "The data
> is invalid" is displayed from windows media player. I cannot figure
> out what is specific about wmv's that they will not stream.
> Thanks Before Hand,
> Adiel
>
No, if I click on the link and choose "Save target as", the error is:

Internet Explorer cannot down from ... _ctl18$lnkLoadImageItem','').

I can understand the above error because the system has to call the
function before it can actually download the file. Basically the
function above is being called from a LinkButton. I have also tried
calling the function from a regular button and same results: I can load
gifs, pdfs, jpgs, etc but windows video files (wmv) receive the error
"The data is invalid" when the system starts Windows Media Player.
Update:

The error when testing on system with Windows Media Player Version
7.10.00.3077 is "The data is invalid"

The error when testing on system with Windows Media Player Version
10.00.00.3700 is "Windows Media Player cannot play the file. The
Player might not support the file type or might not support the codec
that was used to compress the file." and if you click on "More
Information", the error is "C00D1199: Cannot play the file" Error ID =
0xC00D1199, Condition ID = 0x00000000.

Thanks,
Adiel

the easiest way to convert a .net windows app to web app?

Hi all,

I would like to know what is the easiest way to convert a
VB.net window application to a web application?

Thanks in advance!
tom> I would like to know what is the easiest way to convert a
> VB.net window application to a web application?

Do you mean ASP.Net?

Anders
Yes. We want to convert a .net window app to asp.net.
Thanks for your response.

>--Original Message--
>> I would like to know what is the easiest way to convert
a
>> VB.net window application to a web application?
>Do you mean ASP.Net?
>Anders
>
>.
> >> I would like to know what is the easiest way to convert
> a
> >> VB.net window application to a web application?

U can't do that directly...at all.

Maybe you can reuse your datalayer, (if you got one) and webservices (if
have such) and maybe someone of your util classes and or custom collections.

The problem about the windows gui and webpages differ SO much and is not
compareable. Not even with the aproach with asp.net.

But you will have an easier way converting your projects "code logic",
because you can seperate ypur visual design and logic design (code behind
files)

I dont know if you wanted to know if there was utility or so? Or you just
wanted some guidelines.

You could (Dangerous grund) look at deploying your application with notouch
technology.
http://msdn.microsoft.com/library/d...etframework.asp

But its problbly not what ypu are looking for.

Plz specify want your wanna know and we wil try and help you.

Regards,
Anders

Thursday, March 22, 2012

The format of the file Microsoft.Practices.EnterpriseLibrary.Data is invalid

I got this error when I moved my application to a new Windows 2003
server. I installed and recompiled the
'Microsoft.Practices.EnterpriseLibrary - June 2005" then added these
assemblies to the development machine's Assembly Cache. The assemblies
version appears to be 1.1.0.0. I changed the project reference to the
newly compiled EnterpriseLibrary DLLs. The Web.Config of my
application root, I also have the following <configSections>. I don't
know why at runtime it is still asking for
Microsoft.Practices.EnterpriseLibrary.Data, Version=1.0.0.0. Please
help. Thanks.

======================== My Web.Config (partial)
==========================
<configSections>
<section name="enterpriselibrary.configurationSettings"
type="Microsoft.Practices.EnterpriseLibrary.Configuratio n.ConfigurationManagerSectionHandler,

Microsoft.Practices.EnterpriseLibrary.Configuratio n,
Version=1.1.0.0,
Culture=neutral,
PublicKeyToken=60c24972b7c20af7" />
</configSections
<enterpriselibrary.configurationSettings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
applicationName="DMS_ASPX"
xmlns="http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/configuration">
<configurationSections>
<configurationSection xsi:type="ReadOnlyConfigurationSectionData"
name="dataConfiguration" encrypt="false">
<storageProvider xsi:type="XmlFileStorageProviderData"
name="XML File Storage Provider" path="dataConfiguration.config" />
<dataTransformer xsi:type="XmlSerializerTransformerData"
name="Xml Serializer Transformer">
<includeTypes />
</dataTransformer>
</configurationSection>
</configurationSections>
<keyAlgorithmStorageProvider xsi:nil="true" />
<includeTypes />
</enterpriselibrary.configurationSettings
========================= Runtime Error =========================
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.BadImageFormatException: The format of the
file 'Microsoft.Practices.EnterpriseLibrary.Data' is invalid.

Source Error:

[No relevant source lines]

Source File: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Tempo rary
ASP.NET Files\root\88f31b66\ffb9ac8b\x-56vhi4.0.cs Line: 0

Assembly Load Trace: The following information can be helpful to
determine why the assembly 'Microsoft.Practices.EnterpriseLibrary.Data'
could not be loaded.

=== Pre-bind state information ===
LOG: DisplayName = Microsoft.Practices.EnterpriseLibrary.Data,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=60c24972b7c20af7
(Fully-specified)
LOG: Appbase = file:///C:/Inetpub/DMS_Net
LOG: Initial PrivatePath = bin
Calling assembly : DMS_ASPX, Version=0.0.0.0, Culture=neutral,
PublicKeyToken=null.
===

LOG: Publisher policy file is not found.
LOG: No redirect found in host configuration file
(c:\windows\microsoft.net\framework\v1.1.4322\aspn et.config).
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\confi g\machine.config.
LOG: Post-policy reference: Microsoft.Practices.EnterpriseLibrary.Data,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=60c24972b7c20af7
LOG: Attempting download of new URL
file:///c:/windows/microsoft.net/framework/v1.1.4322/Temporary ASP.NET
Files/root/88f31b66/ffb9ac8b/Microsoft.Practices.EnterpriseLibrary.Data.DLL.
LOG: Attempting download of new URL
file:///c:/windows/microsoft.net/framework/v1.1.4322/Temporary ASP.NET
Files/root/88f31b66/ffb9ac8b/Microsoft.Practices.EnterpriseLibrary.Data/Microsoft.Practices.EnterpriseLibrary.Data.DLL.
LOG: Attempting download of new URL
file:///C:/Inetpub/DMS_Net/bin/Microsoft.Practices.EnterpriseLibrary.Data.DLL.

Stack Trace:

[BadImageFormatException: The format of the file
'Microsoft.Practices.EnterpriseLibrary.Data' is invalid.]
DMS_ASPX.Helper.DataBroker..ctor() +0
DMS_ASPX.form.main..ctor() +53
ASP.main_aspx..ctor() in
c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Tempo rary ASP.NET
Files\root\88f31b66\ffb9ac8b\x-56vhi4.0.cs:0

[TargetInvocationException: Exception has been thrown by the target of
an invocation.]
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly) +0
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.Web.UI.TemplateControlParser.GetCompiledIns tance(String
virtualPath, String inputFile, HttpContext context) +164

[HttpException (0x80004005): Failed to create page of type
'ASP.main_aspx'.]
System.Web.UI.TemplateControlParser.GetCompiledIns tance(String
virtualPath, String inputFile, HttpContext context) +341
System.Web.UI.PageParser.GetCompiledPageInstanceIn ternal(String
virtualPath, String inputFile, HttpContext context) +43
System.Web.UI.PageHandlerFactory.GetHandler(HttpCo ntext context,
String requestType, String url, String path) +44
System.Web.HttpApplication.MapHttpHandler(HttpCont ext context,
String requestType, String path, String pathTranslated, Boolean
useAppConfig) +699

System.Web.MapHandlerExecutionStep.System.Web.Http Application+IExecutionStep.Execute()
+95
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously) +173

------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300Ok. I solved this problem myself. It turns out that the Enterprise
Library Configuration utility created two .config files in the
application root:

web.config
dataconfiguration.config

I changed the reference version in both of the config file to the
correct version.
Ok. I solved this problem myself. It turns out that the Enterprise
Library Configuration utility created two .config files in the
application root:

web.config
dataconfiguration.config

I changed the reference version in both of the config file to the
correct version.